Start process synchronously and return results Back
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 05:49 AM
http://forums.activiti.org/content/starting-process-instance-synchronously
Especially in OLTP or embeded use cases, one wants to run the workflow and get the results synchronously. In some cases there is no real database behind or the performance requirements are too strict to enable historization.
What I would like to suggest, is something like this:
First the output variables should be introduced exactly like subprocess, only for the main process. Here is an example:
<process id="vacationRequest" name="Vacation request"> <extensionElements> <activiti:out source="someVariableInSubProcss" target="nameOfVariableInMainProcess" /> </extensionElements> <startEvent id="request" activiti:initiator="employeeName"> …
then it could be something like :
Map<String,Object> outcome = myRuntimeService.startInstance("myProcess", vars);
will start the process, wait until it ends, then preserves and returns the result from context and not history tables.
I can try to see how I can implement it.
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 05:53 AM
<code>
Map outcome = runtimeService.startInstanceSync("myProcess", vars);
</code>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 06:25 AM
Looks great, fits exactly with what I had in mind. We could then enhance the designer UI to map these output variables like it is done in call activity mapping.
2nd idea :
Maybe an even simpler approach would be to always return in the map all variables in scope at the end of the process, so you don't even need to define the mapping, just to add these startInstanceSync methods in the API.
Honestly I’m not sure it really adds that much value to specify which variables are published at the end of the process so I would recommend the 2nd idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 08:44 AM
Currently, you can use a process-end listener (and potentially the BPMNParseHandler approach to add listeners to any process to keep BPMN xml unaware of spacial handling) that saves the process-variables etc. to a thead-local map. After you have called the startProcessByXXX() you access the map and have a blast

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 10:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2013 10:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2013 05:22 AM
If your process is 100% synchronous, simply pass an object in the variables map, and populate the object values during process execution.
When your process finished, the object will now have all the values set. This already works now and doesn't need any new implementation work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2013 08:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2013 12:28 PM
http://forums.activiti.org/content/out-variables-primary-process-proposal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2013 05:41 AM
Activiti has never interfered with client threads so far, and I'd like to keep it that way, it keeps things simple and understandable.
If you really need it, it's very easy to do yourself with thread waiting and polling the service.
