-1
    public void configure(StateMachineConfigurationConfigurer<States, Events> config) throws Exception {
    config
            .withConfiguration()
            .machineId("test")
            .autoStartup(false)
            .listener(listener());
    }

This code segment allows me to setup a machine with ID "test" but if I want to work in an environment where I can uniquely identify my each machine with some UUID based on some parameter before starting it how I can do that and share same to the event so that when it is coming back it will start the same state machine

    public void start(Request incomingRequest) {

    WorkflowInstance instance = new WorkflowInstance();
    instance.setSomeMessage(incomingRequest.getMessage());
    instance = workflowInstanceRepository.save(instance); //This will generate an UUID which I want to use to get my machine everytime I am coming back and changing the transition
    //ID should be taken from the config? or how as each one will have a separate data
    StateMachine<States, Events> stateMachine = factory.getStateMachine();
    stateMachine.start();
    Message<Events> message = MessageBuilder
            .withPayload(Events.INITIALIZING)
            .setHeader("message", incomingRequest).build();
    stateMachine.sendEvent(message);
   }
Arpit Pandey
  • 69
  • 1
  • 4

1 Answers1

0

You don't need to set machine id in configuaration, instead you can use factory so set it:

Thought factory doesn't keep these machines around and will return new instance every time as it just allows to set machine id.

StateMachine<States, Events> stateMachine = factory.getStateMachine("test");

Next release 1.2.8 will have some additional facilities helping to manage running machines as it looks like that's what you want to do here.

Janne Valkealahti
  • 2,552
  • 1
  • 14
  • 12