Activiti REST start process instance is -not- asynch?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2014 05:06 PM
Hey guys.
I'm using activiti-rest to handle our workflow needs. One of my issues is that when I start a process instance with "runtime/process-instances" this works without problem but it will only send a response back to the client once all the tasks that can be executed are done running.
This is a huge issue as some of the tasks take a long time to complete (video encoding, etc..) and it just makes the client hang forever.
Is there a reason for this?
For full disclosure here's the process definition:
I essentially don't get a response back from activiti-rest until both of these commands are executed and done running. Weird or normal?
I'm using activiti-rest to handle our workflow needs. One of my issues is that when I start a process instance with "runtime/process-instances" this works without problem but it will only send a response back to the client once all the tasks that can be executed are done running.
This is a huge issue as some of the tasks take a long time to complete (video encoding, etc..) and it just makes the client hang forever.
Is there a reason for this?
For full disclosure here's the process definition:
<process id="node-pre-process" name="Generates node information"> <startEvent id="theStart" /> <sequenceFlow id="flow1" sourceRef="theStart" targetRef="consoleMeta"></sequenceFlow> <serviceTask id="consoleMeta" name="Retrieve Meta Data" activiti:type="shell" > <extensionElements> <activiti:field name="command"> <activiti:expression>${yiiCommand}</activiti:expression> </activiti:field> <activiti:field name="arg1" stringValue="node/add-meta" /> <activiti:field name="arg2"> <activiti:expression>${nodeKey}</activiti:expression> </activiti:field> </extensionElements> </serviceTask> <sequenceFlow id="flow2" sourceRef="consoleMeta" targetRef="consoleBase"></sequenceFlow> <serviceTask id="consoleBase" name="Generate Base Image" activiti:type="shell" > <extensionElements> <activiti:field name="command"> <activiti:expression>${yiiCommand}</activiti:expression> </activiti:field> <activiti:field name="arg1" stringValue="node/generate-base" /> <activiti:field name="arg2"> <activiti:expression>${nodeKey}</activiti:expression> </activiti:field> </extensionElements> </serviceTask> <endEvent id="theEnd"/> <sequenceFlow id="flow3" sourceRef="consoleBase" targetRef="theEnd"></sequenceFlow> </process>
I essentially don't get a response back from activiti-rest until both of these commands are executed and done running. Weird or normal?
Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2014 02:45 AM
Hi,
That's normal with this process definition, because tasks run synchronously by default.
You can add an async attribute to a service task to make it asynchronous and then the REST service will send a response quickly.
Best regards,
That's normal with this process definition, because tasks run synchronously by default.
You can add an async attribute to a service task to make it asynchronous and then the REST service will send a response quickly.
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 05:46 PM
Great thanks for the info!! Do you know if this works with shell tasks? As the following doesn't seem to work (I added an async tag to the second Service task):
<process id="node-pre-process" name="Generates node information">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="consoleMeta"></sequenceFlow>
<serviceTask id="consoleMeta" name="Retrieve Meta Data" activiti:type="shell" >
<extensionElements>
<activiti:field name="command">
<activiti:expression>${yiiCommand}</activiti:expression>
</activiti:field>
<activiti:field name="arg1" stringValue="node/add-meta" />
<activiti:field name="arg2">
<activiti:expression>${nodeKey}</activiti:expression>
</activiti:field>
</extensionElements>
</serviceTask>
<sequenceFlow id="flow2" sourceRef="consoleMeta" targetRef="consoleBase"></sequenceFlow>
<serviceTask id="consoleBase" name="Generate Base Image" activiti:type="shell" activiti:async="true" >
<extensionElements>
<activiti:field name="command">
<activiti:expression>${yiiCommand}</activiti:expression>
</activiti:field>
<activiti:field name="arg1" stringValue="node/generate-base" />
<activiti:field name="arg2">
<activiti:expression>${nodeKey}</activiti:expression>
</activiti:field>
</extensionElements>
</serviceTask>
<endEvent id="theEnd"/>
<sequenceFlow id="flow3" sourceRef="consoleBase" targetRef="theEnd"></sequenceFlow>
</process>

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 05:56 PM
My bad it actually works as expected! thanks

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2014 06:18 PM
I just realized that sync doesn't take expressions. This is a bit of an issue if you want to unit test your workflows. You can't programmatically set the async to false when running unit tests but keep it at true for production use.

