AnsweredAssumed Answered

Why is the TASK_CREATED event sent before flushing the tasks to the DB?

Question asked by jfelix on Apr 21, 2015
Latest reply on Apr 22, 2015 by martin.grofcik

We have a listener for TASK_CREATED events that triggers some work to be done in our application.
As we need some custom info besides the given by the Activiti tasks, we have a DB table with those attributes and a reference to the Activiti task IDs.

Usually it works fine but sometimes we have errors because the task is inserted in our table (as a consequence of receiving the TASK_CREATED event) but it is not flushed to the Activiti task DB table due to an Activiti exception.
This exception makes Activiti rollback the task creation transaction and so, when we search for it in Activiti using the Task Service it always returns null.

Was the event dispatching mechanism designed to be this "optimistic" or is this a bug? Is there a way to capture TASK_CREATED events only after the tasks are flushed into the Activiti DB?

Thanks in advance.