1 Reply Latest reply on Jul 21, 2011 10:19 AM by José Peñalba Morales

    How to know if a token is running

    José Peñalba Morales Newbie

      First of all, hi all there, I am new on this community.

       

      Second, sorry for my bad English.

       

      I hope someone can help me with this problem (sorry if this is a silly question).

       

      It is related with:

      http://community.jboss.org/message/386777

       

      I have a concurrence problem. A user manually ends a pending task instance (TaskInstance.end()). The following activities until next "wait state" are long running (several minutes). We would like the user to synchronously wait until end of execution.

      As the user is working at a web environment he can, at any moment, look for task instances to end (JbpmContext.getTaskMgmtSession().findTaskInstances(actorId) at another thread). If the user perform this query while a the previous activities are not finished, he finds the same task instance as before an is able to end it again. This leads to a "StaleObjectStateException" on the token in one (or both) of the threads with unpredictable results.

       

      I understand the suggestion on the related discussion, any long time activities can be executed asynchronously in order to avoid this problem. But due to our needs (the user should be able to perform all activities on the process instance synchronously) this is not the desired solution.

       

      ¿Is there any way to force jBpm to flush database operations when "save" is called and not wait until the context is closed?

      For example, ¿could be valid calling on "task-end" event?:

      jbpmContext.save(taskInstance);

       

      Or for example, ¿modifing the hibernate session flush mode could be a valid solution? ¿Does it have undesired consequences?

      Something like:

      jbpmContext.getSession().setFlushMode(FlushMode.AUTO)

      or

      jbpmContext.getSession().setFlushMode(FlushMode.ALWAYS)

       

      This could help us to avoid the concurrence problem.

       

      Many thanks in advance.

       

      Regards,

      José