Hi everyone,
I am working with the ExternalTask Client pattern and encountered a problem.
The situation is the following:
I have this example process. In the first task I simply print “start” to the console and in the last task I print “end” to the console, so I can check when the process arrives in which step. The task in the middle should be executed with an ExternalTask Client.
The code for the ExternalTask client is shown in the following picture. The code prints the ID of the processInstance, sleeps for a few seconds and prints the ID again.
Now when I start three instances of this process in the Camunda Tasklist all three processes arrive at the middle Task and wait to be completed. If I now execute the main method of this ExternTask client two times (to get two instances of the client) there seems to be a problem
The first instance of the ExternalTask client prints the following:
2019-02-05 10:39:59,662 [INFO ] ExternalTaskExample - start
2019-02-05 10:40:02,008 [INFO ] ExternalTaskExample - end
2019-02-05 10:40:02,572 [DEBUG] ExternalTaskExample - [f5b68cc6-2929-11e9-919d-98b18b5b5347] start
2019-02-05 10:40:10,574 [DEBUG] ExternalTaskExample - [f5b68cc6-2929-11e9-919d-98b18b5b5347] end
2019-02-05 10:40:10,712 [DEBUG] ExternalTaskExample - [f7e309bd-2929-11e9-919d-98b18b5b5347] start
2019-02-05 10:40:18,712 [DEBUG] ExternalTaskExample - [f7e309bd-2929-11e9-919d-98b18b5b5347] end
2019-02-05 10:40:18,791 [DEBUG] ExternalTaskExample - [fa5d7ea4-2929-11e9-919d-98b18b5b5347] start
2019-02-05 10:40:26,792 [DEBUG] ExternalTaskExample - [fa5d7ea4-2929-11e9-919d-98b18b5b5347] end
2019-02-05 10:40:26,812 [ERROR] client - TASK/CLIENT-03004 Exception on external task service method invocation for topic ‘external-test’:
org.camunda.bpm.client.exception.NotAcquiredException: TASK/CLIENT-01007 Exception while completing the external task: The task’s most recent lock could not be acquired
and the second instance prints this:
2019-02-05 10:40:02,438 [INFO ] ExternalTaskExample - start
2019-02-05 10:40:03,951 [INFO ] ExternalTaskExample - end
2019-02-05 10:40:24,301 [DEBUG] ExternalTaskExample - [fa5d7ea4-2929-11e9-919d-98b18b5b5347] start
2019-02-05 10:40:32,304 [DEBUG] ExternalTaskExample - [fa5d7ea4-2929-11e9-919d-98b18b5b5347] end
This behaviour shows that the process instance with the id “fa5d7ea4-2929-11e9-919d-98b18b5b5347” is processed two times. I am wondering why this happens.
On the other hand, the last task in the process that only prints “end” to the console is executed three times (as it should be) but I also get the following error:
External Task fa64d1a9-2929-11e9-919d-98b18b5b5347 cannot be completed by worker ‘062a2cd5-90a7-4ec8-966c-d2d2b9810dba’. It is locked by worker ‘2a23073d-d746-49b9-9035-cb2056585a17’.
I hope someone can explain what the problem with this example is. Is there anything that needs to be configured for starting the ExternalTask client multiple times? Thanks in advance.
Regards
Michael