cancel
Showing results for 
Search instead for 
Did you mean: 

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

jfelix
Champ in-the-making
Champ in-the-making
Hi,

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.
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi João,

The problem is that DB flush optimizes insert/deletes. I think this was done because of that.

Regards
Martin