9 Replies Latest reply on Oct 18, 2006 4:55 AM by Wang Xin

    JbpmContext: when to create new vs. get current

    Brad O'Hearne Newbie

      The general question: when should you create a new JbpmContext vs. get the current context?

      The reason that this question hasn't been completely clear to me is because of a couple reasons:

      1) It appears that any saving of data to the database (such as process instance state) doesn't commit until the JbpmContext is closed. This then seemed to suggest that a JbpmContext needed to be created and closed each time data needed to be saved to the database.

      2) While I have seen documentation saying that JbpmConfiguration was re-entrant, I have seen no such indication that JbpmContext is. I wasn't sure that if I was working with a JbpmContext in a servlet (or several servlets) whether it would be safe for all of them to be operating simultaneously on the current jbpmContext, rather than all using their own jbpmContext instance for thread safety.

      What is the recommended approach to using jbpmContexts? Can the "current" jbpmContext be used across multiple servlets and multiple threads without there being a problem, or does each one need to create its own jbpmContext, and how does this affect the committing of data to the database?

      Thanks for your help,

      Brad