Not able to get FlowableEngineEventType.TASK_CREATED after Boundary timer event trigger

Hi Team,

I’m facing the below problem in flowable.

I used a timer(boundary timer event) from one task(test1), and if the task is not completed in 20s, it will move to a task called Test2 instead of Test3. But during this timer event triggered, the task are created in the Engine, but the listener is not able to find the created new task.

image

I’m using springboot application and the code is as below.

public class CreateTaskListener implements FlowableEventListener
{

@Override
public void onEvent(FlowableEvent event)
{
    if (event instanceof FlowableEngineEntityEvent) {
    	System.out.println(event.getType());
        if (event.getType() == FlowableEngineEventType.TASK_CREATED) {
            TaskEntity task = (TaskEntity) ((FlowableEngineEntityEvent) event).getEntity();
            try {
                restClient rest = new restClient("api-env");
                rest.createTask(task);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}

I assume, looking at your code, that you are sending out REST request to somewhere else and there want to query the tasks?

The task entity won’t be in the database until the transaction has been committed. The solution is to send out this request only when the transaction has been committed. This is possible by enabling the isFireOnTransactionLifecycleEvent, see more info here: https://flowable.com/open-source/docs/bpmn/ch03-Configuration/#event-listener-implementation

Team,

This is working after setting config.setAsyncExecutorDefaultTimerJobAcquireWaitTime(10) in configuration.

This setting will set the delay between two checks of the async executor for new work. Not sure how this solves the problem (i’m guessing there is a race condition between db transaction commit and the other service querying for the task).