Kris Verlaenen [
http://community.jboss.org/people/KrisVerlaenen] created the discussion
"Re: jBPM 5.1 in a real world web application"
To view the discussion, visit:
http://community.jboss.org/message/613360#613360
--------------------------------------------------------------
Regarding the scope of the session: the session itself is threadsafe, and especially when
using persistence, we make sure multiple threads are not changing the same data (as this
would only result in conflicts anyway). Depending on the required performance, it might
be possible to simply use one session to run all requests. In this case however, I would
recommend using one session per case (where a case is long-lived so could span multiple
requests and multiple process instances but typically is about one isolated set of data).
The main reason is that this will prevent data from other unrelated cases to influence
your execution, which is especially possible once you start using rule tasks. So whenever
a request comes in, look up the related case id somehow and try to reload the session from
the database (or create a new session if this is a new case).
Regarding reloading the sessions, the only thing you should make sure of is that, if you
use timers, that the timers are actually re-registered (so this automatically leads to
question 4), as timers are part of the session state, and those timers will only trigger
if that session is active. There are a few possible approaches here: (1) use a
centralized session to put your timers in, and make sure that session is restored after
reboot, so that timers will still trigger on that session, or (2) use some kind of
persistent timer trigger (like quartz) that would reactivate the session if a timer would
need to trigger (we have some community work on this as an extension of the normal timer
service but it's not completely integrated yet).
So I would recommend using a session per case and simply disposing your session once
you're done processing the request, and the session will simply be reloaded for the
next request for that case. And registering all timers to a centralized session before
disposing the session so that they still get triggered if the session is disposed, and
simply restoring that session in case of restart.
Hope this helps,
Kris
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/613360#613360]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]