cancel
Showing results for 
Search instead for 
Did you mean: 

Lightweight async via Groovy & REST?

roblong
Champ in-the-making
Champ in-the-making
First, kudos to the entire team, Activiti's been a treat to learn (even for a Java newbie).

Issue: I've had surprising success with fairly complex Activiti workflows, but have failed to integrate Activiti into our async python/php infrastructure.

Use case - Amazon Mechanical Turk process:
- intiate process via human task/form
- enqueue task/process vars via script task
    —  (groovy: add process Vars to Redis queue via jedis)
    —  problem: ProcessInstanceID or BusinessKey not available within <script>
- do external work (Amazon Turk via our existing systems)
    —  may be a multi-day process depending on scope
- integrate back into workflow via REST
    —  problem: assuming I have ProcessInstanceID/BusinessKey  REST api returns png diagram, but not json of current task(s)  (service/process/<123>/diagram)
- wait for human approval
- complete process

Pulling hair out a bit trying to work around these two issues:

  o How to enqueue correlation keys & process variables via groovy/jython script?

  o Determine current task(s) for given correlation key via REST?

I assume I'm missing something obvious… or more likely I'm an edge case, relying on experimental interfaces and just need to bust out the Java Beans/Spring for dummies?

Appreciate any pointers.

- Rob
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
You can just use varaibles in you script. So if you have a process-variable with name "myProcessvar", it will be available in the script-context as myProcessVar. The business-key is curently not exposed in scripts. A workaround (delegateExecution.getBusinessKey() will be available in activiti 5.6) could be storing the businessKey as variable:

- Use a execution/task listener right before the script-task, using an expression, eg:

<extensionElements>
      <activiti:executionListener expression="${execution.setVariable('theKey', execution.getBusinessKey()}" event="take" />
    </extensionElements>
- In scriptTask, business-key is available under variable theKey

About the REST-API. Not all java-api calls are available through rest. So getting al tasks for a processInstanceID is not possible… You'll have to extend the activiti-rest or write your own servlet/rest-endpoint in the java-app that calls the Activiti java-API I'm affraid…
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.