After executing my BPMN workflow using the Camunda Engine I noticed that one task has been executed twice. The same behaviour occured when I tested other diagrams. As I understand the situation at present, this certain task is the one that sets a execution variable first:
In this example “Buy Pizza” would be executed twice since it is the first task where a variable is set. All following tasks would be executed just once, regardless of wether the task sets a variable or not.
Asynchronous Before property of the affected tasks is enabled (otherwise the variables won’t be set). The implementation is set to
Connector because I use them as
http-connectors that perform a REST call using the
GET method. The exact properties are set like in this example. All of the tasks are service tasks.
Does anyone know what this problem is caused by? Thanks alot!
to better understand, whta is going on, I would recommend to check historic job logs (https://docs.camunda.org/manual/7.8/reference/rest/history/job-log/). I suppose, that some errors, rollbacks and then retries are involved in the situation. For each asynchronous activity the job is created, so analyzing historic job log, you can understand, what’s going on.
Thanks for your advice. I retrieved the following exception message from the job log:
Execution of 'UPDATE ExecutionEntity[...]' failed. Entity was updated by another transaction concurrently.
In my current understanding the error is due to the fact that the tasks are executed asynchronous. But disabling the
Asynchronous Before checkbox causes that the variables won’t be set. Do you know a possible reason for this or is there a solution for the problem with asynchronous tasks?
Which database and Camunda version are you using?
I’m using Camunda 7.8.0 with MySQL as database.
Can you post your BPMN XML, the real one or the minimal failing, and point out which task is failing?
Executing my example will cause the first task to be executed twice if I set a string variable in it. The original
url parameter is a local URL of my project. If the URL is called by the task, the variable will be set. Obviously the first attempt fails, so the task will be executed a second time.
how exactly do you set the variable? I don’t see any output parameters in your connector configuration. Is it the remote service, that sets the variable? Can you post the example, how is it being done?
I’m going to explain what my workflow does. This minimal working example includes two service tasks with the
connector implementation. They call my php application via
The called URLs are configured in the task’s input parameters. In addition, I append the process instance ID as a parameter. That’s everything what the workflow does.
The execution variables are set by my web application. When the
/buy_pizza URL is called, PHP sets a variable:
This works without any problems.
$pid is the parameter from the URL that the task called.
self::$API is just an instance of the Camunda PHP SDK’s
The second task in my example also calls such a URL and the PHP application sets the variable the exact same way.
All variables are set properly, but:
Buy Pizza is executed twice by the engine. If I didn’t set a variable for that task in my application, it would be executed just once.
That’s my current problem and up to now I don’t really understand what is actually happening.