Instant insert/update of variable inside JavaDelegate execution?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2015 10:48 AM
We have use-case in which we perform some relatively long-running operations (think of up-to 30 sec to 1 minute) as part of a JavaDelegate.execute(). We have the requirement to report the progress of the execution of the JavaDelegate, which we currently do as updates of variables inside DelegateExecution. These variables are simultaneously read within a REST call of our backend via RuntimeService.getVariable(). Still we observe that the variables we set in the JavaDelegate implementation are committed to the database (and their up-to-date values are visible via RuntimeService.getVarialbe() call in our web request-handling thread) only after a successful finish of the execute() method.
What we want to achieve is direct insert/update of the variables in the database during the JavaDelegate.execute() method execution. One workaround that we find to make this happen was to set the progress variables via RuntimeService.setVariable() call in a new Thread, which is not very clean. So, is there any recommended/more elegant way to achieve our goal?
Thanks,
Nikolay
What we want to achieve is direct insert/update of the variables in the database during the JavaDelegate.execute() method execution. One workaround that we find to make this happen was to set the progress variables via RuntimeService.setVariable() call in a new Thread, which is not very clean. So, is there any recommended/more elegant way to achieve our goal?
Thanks,
Nikolay
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2015 11:10 AM
That is the way Activiti works: during the execution of your delegate a db transaction is kept open and it is committed at the end. There is no clean way to get what you want with Activiti, except storing it in a Threadlocal on the service task or a table outside of Activiti.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2015 05:36 AM
Thanks, we also took the external table approach as we don't want to mess with Acitiviti internals.
