Hi, we are using Activiti 5.11 and are modeling a business process with three tasks:
Task 1 - Java service task that sends a JMS message
Task 2 - Receive Task that puts the BPM in a 'wait' state
Task 3 - Java service task that gets called by the JMS listener for the message sent in Task 1; this task looks up the appropriate BPM instance (based on process instance id, which is sent as part of the JMS message), and signals it to resume.
The issue we are seeing is that the BPM runtime information is not being written to the database until Task 2 completes. However, when Task 1 sends the JMS message, Task 3 is almost instantaneously firing and trying to signal the BPM to resume – since Task 2 has not yet completed, Task 3 does not find any Activiti runtime information in the database and therefore throws an exception.
Now, we can solve this problem by introducing a latency in Task 3, or checking the database for runtime information before trying to signal the BPM in Task 3. However, we are wondering if there is a better way to do this? Ideally, we want to make sure the BPM runtime information has been written to the database *before* sending the JMS message –
* Can we force the process instance to commit in Task 1 or Task 2, and then send our message?
* Can we attach an execution listener to the receive task "end" event (Task 2), so that we can send our message at that point (after database commit)? (I tried, but was able to attach an execution listener only to the Task 2 "start" event.)
Another possibility could be to somehow integrate the BPM/messaging with Mule (which is also in our architecture) if that can give us better control over the database commits and message firing, but we haven't explored this.
FYI, we are using an Oracle database for Activiti, and our spring process engine configuration uses Spring's DataSourceTransactionManager.
Any help with this issue will be much appreciated.