Reading a variable from a task is very slow

Hello,

I am reading a variable that is associated to a certain task like this:

camundaEngine.getTaskService().getVariable(task.getId(), “myVariableName”);

This API call is very slow, it takes 4-5 seconds per call. We do not have much data in our camunda databases yet. I wonder if anyone has an idea how to speed the reading of task variables up, because right now it is just way too slow.

thanks and kind regards,
Jens

I found a solution:
When setting the variable, I provided the current activityID:
execution.setVariable(“variableName”,“value”,“myActivityId”);
This way reading the variable via TaskService later is working a lot faster!

1 Like

Hi @Jens_Stahl
Interesting solution. I am interested if it will be enough with a big amount of processes and variables inside Camunda database. From my experience, if you need to retrieve some specific variables for tasks, sooner or later, when the amount of data in Camunda will grow, it becomes a pretty long process. So in this case you can implement a custom handler for history events that are produced by Process Engine (look at the related picture)
image

Here, in addition to default DbHistoryEventHandler you can add your custom handle and inside it, you can just write required variables to your own custom table inside Camunda database.
Here you can see how this can be implement: GitHub - hedza06/cam-task-activities: Usage of Camunda History Stream for human task managment

1 Like

Hi @Yurii_Shchur,

thanks for pointing me to the HistoryEventHandler!
Right now it is very convenient to just set and read all the required data directly
into the Camunda database. I will let you know how the performance will
develop when we have lots of data in Camunda.

kind regards,
Jens

1 Like