Hi everybody!
Can anyone tell me how to make a variable that I set in java service task become visible in process immediately?
If I set it like this:
execution.setVariable("estimated_time", estimatedTime);
or this:
execution.getProcessEngineServices().getRuntimeService().setVariable(execution.getId(), "estimated_time", estimatedTime);
I can see it only after service task is completed which is not what I want.
How do you verify that a variable is set?
from camunda cockpit
Camunda flushes and commits database changes only at the end of a running command. This is why you cannot see it before the next wait state is reached in the process. Also, this is good behavior in terms of transaction isolation, e.g. think about the case in which the service task fails after the variable is set. If you need to have more fine-grained commit points in the process, have a look at asynchronous continuations: https://docs.camunda.org/manual/7.7/user-guide/process-engine/transactions-in-processes/#asynchronous-continuations.
Cheers,
Thorben
OK, thanks!
It seems like I’ll have to make a listener for calculating estimated time
Well, it seems like listener is a part of the same transaction, because if I attach a start listener a variable doesn’t show either until the task is finished.
What exactly would you like to measure? How did you implement the listener?
Note that when you call #setVariable
on specific delegate execution, you can retrieve it via #getVariable
even when its in the same transaction, as this API works on the engine’s current local state.
I have service tasks in several places across the process. These service tasks parse, validate and write to database certain documents. They can be very long in terms of time. So what I want is to calculate estimated processing time and show it to user on a web form so that he knows how long he has to wait. The service task is written on java, forms are managed by ruby. Hence I need to put a variable into the camunda process which will be read by ruby. The relevant part of a process looks like this: