Open Per0xyde opened 2 years ago
Hello, I am facing the same issue.
I want to define a state machine factory with the goal to instantiate any number of machine from that factory to be ran in parallel. Because of this, my IDs will be dynamically generated
I wanted to use @WithStateMachine(name = FACTORY_NAME)
in order to use context integration for a cleaner project because, as OP stated, the documentation pretends that every machine with from the factory identified by name should be bound to the annotated methods of the class.
As it currently stands this is not correct. it doesn't seems like the name defined in the annotation is ever used anywhere in the spring code. The annotation is fetched a couple times but only to check the contextEvent param. After that the annotations details are systematically discarded without passing the name to anything
The issue is quite similar to #941, except that I am using StateMachineService to create a state machine with dynamically generated ID and persist it.
I attach a small sample to illustrate the issue : StateMachineExample.txt pom.txt
My goal is :
To do so :
According to the documentation, if I don't specify any ID in @WithStateMachine, it will match all state machines generated by the factory.
My issue :
Whenever I send an event to a state machine created at runtime thanks to StateMachineService, the method annotated with @OnStateChanged is ignored. It only works if I specifically write an ID @WithStateMachine(id = "1"), and thus it works only for the state machine which will have the dynamically gerated ID of 1.