Service Task Activity repeatedly started

In my workflow, I have a start event, service task and an end event
Service Task is used to launch robots in a management console or perform other tasks.
Capture

I’ve also added an implementation of FlowableEventListener, I’ve added logs so that whenever an event occurs, it’s displayed in console logs for now
While the robots are running, I see the particular piece repeatedly in my logs,

Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: JOB_EXECUTION_SUCCESS
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: HISTORIC_ACTIVITY_INSTANCE_CREATED
Current event is: ACTIVITY_STARTED
Started activity: serviceTask //assumption is this activity should be started only once instead of multiple times

My question is based on the last line “Started activity: service task”, if service task is getting started repeatedly, my guess is maybe after certain time, service task activity is still in progress, it is attempted to get started, not sure if that’s correct!!!

Also, below are the order of events created in order, in a case where execution of service task didn’t take that much time:

Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: HISTORIC_PROCESS_INSTANCE_CREATED
Current event is: PROCESS_CREATED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: VARIABLE_CREATED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: VARIABLE_CREATED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: VARIABLE_CREATED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: VARIABLE_CREATED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: HISTORIC_ACTIVITY_INSTANCE_CREATED
Current event is: PROCESS_STARTED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED

Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: JOB_EXECUTION_SUCCESS
Current event is: ACTIVITY_STARTED
Started activity: startEvent

Current event is: SEQUENCEFLOW_TAKEN
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: JOB_EXECUTION_SUCCESS
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: HISTORIC_ACTIVITY_INSTANCE_CREATED
Current event is: ACTIVITY_STARTED
Started activity: serviceTask

Current event is: ACTIVITY_SIGNALED
Current event is: HISTORIC_ACTIVITY_INSTANCE_ENDED
Current event is: ACTIVITY_COMPLETED
Completed activity: serviceTask

Current event is: SEQUENCEFLOW_TAKEN
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: ENTITY_CREATED
Current event is: ENTITY_INITIALIZED
Current event is: HISTORIC_ACTIVITY_INSTANCE_CREATED
Current event is: ACTIVITY_STARTED
Started activity: endEvent

Completed activity: endEvent
Current event is: ACTIVITY_COMPLETED

Current event is: HISTORIC_ACTIVITY_INSTANCE_ENDED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: VARIABLE_DELETED
Current event is: ENTITY_DELETED
Current event is: VARIABLE_DELETED
Current event is: ENTITY_DELETED
Current event is: VARIABLE_DELETED
Current event is: ENTITY_DELETED
Current event is: VARIABLE_DELETED
Current event is: ENTITY_DELETED
Current event is: ENTITY_DELETED
Current event is: PROCESS_COMPLETED

Let me know if any information is missing from my end

From your logging output, it appears that there is an event for starting the service task and another completing it. I don’t see the issue.

In the upcoming 6.5.0 release, we’re adding a logging session feature, that can give more insight into what is going on.

Yes, there is an event to start service task and another to end it, what I’m confused with that after around every 5-6 minutes, this starting of service task happens repeatedly for the same process instance

Is “Launch BOTs” asynchronous? It could be that it’s taking long enough that the job is timing out and getting restarted.

Yes the service task is asynchronous
I have an API to start process instance and the process instance is also started as async with “.startAsync()”, so that once I start the instance, I can return some meaningful information for the process instance.
I unchecked the asynchronous box of service task, but then I guess due to around time-out of 5 minutes, process instance just got restarted.
Is the duration of time-out configurable somewhere?

The default job lock time is indeed 5 minutes. It can be changed with the property asyncExecutorAsyncJobLockTimeInMillis : https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java#L698

Note that having a long running job also keeps the database transaction open for 5 minutes, this is not ideal. Depending on the type of logic, this might be the only solution. However, often it can be made more performance by having a service task that sends an event to some queue, where it gets processed and then returns to the process when done.