I have created a workflow which as a parallel gateway. From that parallel gateway there are two sequence flows. One goes to a service task (Task B in image attached) and another goes to a subprocess (Multi Loop) (Task C in the image attached). I have marked the service task (Task B) as async="true" in XML, so that activiti is able to retry the task. For retrying I am throwing a BpmnError based on some logic.
I have attached the workflow diagram in the image.
Case1 - Worfklow started for the first time. Flow reaches the async task (Task B). And the async task gets picked up immediately and retries is working correctly.
Case2 - Workflow server running from before. A new request to start to workflow comes. Now when the flow reaches async task (Task B). Activiti takes a long time to pick up this task. It picks it up for sure after some time like (5 minutes or so) but this delay only happening when the workflow request is not the first request to the server.
Async task (Task B) in the first request to workflow gets picked up immediately. The same async task (Task B) in the next requests to workflow takes a lot of time to get picked up.