Open cmcconomy opened 10 years ago
I also miss this. Thanks for the tip cmcconomy.
Can't seem to get a hang of it.
Would be pleased if anyone could post an example how to terminate at/after the last state? I do now want to exit the application just terminate the state handling process, like flow.terminate(), stop() or something like that would be nice.
You need your own executor:
ExecutorService service = Executors.newSingleThreadExecutor();
flow.executor(service);
flow.start();
and then
flow.whenFinalState(new StateHandler<StatefulContext>() {
public void call(StateEnum stateEnum, StatefulContext statefulContext) throws Exception {
System.out.println("STOP. Nothing more to do.");
service.shutdown();
}
});
Thanks that worked!
I'm using easyflow to manage state change in a file parser and so far it's come in quite handy. However one thing I can't figure out is why after I reach a final state, the context reports itself as terminated, but the flow engine keeps going.
Is there a recommended way to exit the entire FlowEngine when your processing is complete?
EDIT: I found a solution, for anyone looking; create your own Executor class, instantiate your EasyFlow object with it, and call shutdownNow() on the executorservice once your context terminates.
Would be nice to have something like that be a built in option though, or at least the ability to tell EasyFlow to terminate directly.