New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SSM in a web application (non-distributed) with multiple requests support #170

Closed
sengopal opened this Issue Feb 5, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@sengopal

sengopal commented Feb 5, 2016

N00bie here. Apologies if my understanding is incorrect.

I am using SSM for a web application which performs something similar to the Persist recipe. However, since the StateMachine object is singular, I am confused as to how would multiple parallel requests work.
Should i be creating a new StateMachine object per request and trigger the event or is there a simpler means to use one instance of the SM, but ensure that each request has its own threadlocal copy of data such as MessageHeaders, currentState etc.,

Can you please clarify?

@jvalkeal

This comment has been minimized.

Contributor

jvalkeal commented Feb 5, 2016

For 1.0.x things are a bit limited because you'd need to control all that yourself(but yes you on a right track). For 1.1.x things around web and scopes are going to be much better implemented in terms of usability. New sample http://docs.spring.io/spring-statemachine/docs/1.1.0.M1/reference/htmlsingle/#statemachine-examples-eventservice was done exactly for this use case and we made a lot of enhancements for all this not to be so difficult from user perspective.

Essentially that sample will will persist(using redis) state machine per user and request and reuse pool of state machines to avoid expensive instantiation(thought instantiation per request is also possible). For 1.1.0.M2 we're doing further enhancements for scoping and especially spring-session.

@jvalkeal jvalkeal added the question label Feb 5, 2016

@sengopal

This comment has been minimized.

sengopal commented Feb 5, 2016

Ah. Thanks so much.That explains a lot. Is the 1.1.X release planned soon.

@jvalkeal

This comment has been minimized.

Contributor

jvalkeal commented Feb 6, 2016

Target is around April/May.

@jvalkeal jvalkeal closed this Feb 6, 2016

@sengopal

This comment has been minimized.

sengopal commented Feb 26, 2016

Just an update. We had to go with squirrel (https://github.com/hekailiang/squirrel) as it satisfies our usecase creating a new State machine object and uses ThreadLocalContext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment