JBoss Community

Re: JBPM 5.4.0-Final: Human Task variable mapping is not working

created by Maciej Swiderski in jBPM - View the full discussion

The issue here is that LocalHTWorkItemHandler has single (always active) instance of LocalTaskService and unfortunately it is shared with TaskCompletedHandler (that is inherited from GenericHTHandler). Which puts us in situation where after some time task is about to be completed and to do so new LocalTaskService instance is created that does the complete operation on task service and sends an event to the runtime engine. That event is received by TaskCompletedHandler and uses LocalTaskService instance from LocalHTWorkItemHandler. That gives us:

1. new instance of LocalTaskService (LTS1) that is created to complete task with persistence context PC1

2. always active instance of LocalTaskService (LTS2) taken from LocalHTWorkItemHandler inside TaskCompletedHandler class which was persistence context PC2

 

when LTS2 checks task status by loading it from db (PC2) it has out of date information as the LTC1 has not yet committed it's changes (flushed from PC1) and thus proceeding with abort of work item handler.

 

A workaround for this would be to extend LocalHTWorkItemHandler and override registerForEvent method to register your own TaskCompletedHandler that will get new LocalTaskService for every event it is going to process. With that persistence contexts will be shared on hibernate session level since they run as part of the same JTA transaction and where created for that transaction.

 

HTH

Reply to this message by going to Community

Start a new discussion in jBPM at Community