07-25-2011 02:41 PM
07-28-2011 08:01 PM
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId())
.activityId("wait")
.singleResult();
assertNotNull(execution);
runtimeService.signal(execution.getId());
This could e.g. be done by a minimal service task that puts a message in a jms queue somewhere, followed by a receive task (wait state! so persistence takes place, so memory is freed) with a timeout on it that makes it continue/loop… After the job finishes normally, the receive task is triggerd.i am confused as to the actual layout of this.
07-28-2011 08:49 PM
if the memory is written out in the wait states, why can't it just be written out after every step in the workflow?That is what Async continuations is about
? or via some java service task call on demand? the functionality exists, it just isn't accessible via service tasks.No, it's not that simple, not if you also want the flow to continue… (it's not extremely complicated either, but needs work)
the user guide calls it a "Java Receive Task"Sorry, my bad… apologies. The reason they call it this way is that there is e.g. no 'jms-receive-task', or 'web-service-receive-task', you can only use the java api. (bpmn has no notion of different reveive tasks, there it is a generic receive task)
http://www.activiti.org/userguide/index … eceiveTask
this would be code that is executed in a java service task that would result in the receiveTask process being executed/started, and then passing a signal to that specific execution of the receiveTask process to leave the waitstate, correct?No, not fully. The starting of the process is done separately (can be confusing to some extend that this is mentioned here)
Execution execution = runtimeService.createExecutionQuery().processInstanceId(piId).activityId(activityId).singleResult();
runtimeService.signal(execution.getId());
would be in the external code ('callback') e.g. an mdb that receives a message that contains the process instance id (piId) and activity id (activityId) which I turned into variables could you elaborate on:Sure
"jms to somebody that does work" can be to a workflow, but it can also be to a 'simple' service (sleep() 😉 What it is does not matter. It is asyc and fully loosely coupled (I hate that term).But you HAVE TO put at least the process instance id and activity id in there so that they can be used in the callback (the combination being the 'correlation'. After that the recv task is a wait-state, so all the commits are done and memory is 'freed'. Then you either receive a message and continue that flow how it is configured or a timeout occurs and the flow does takes a different path. If in this latter case you set 'cancelActivity' to true, the recv task wil disappear. So you have to take this into account in the code above that it might be that you do not find an execution if after a delay you do receive the message. So you get something likeThis could e.g. be done by a minimal service task that puts a message in a jms queue somewhere, followed by a receive task (wait state! so persistence takes place, so memory is freed) with a timeout on it that makes it continue/loop… After the job finishes normally, the receive task is triggerd.i am confused as to the actual layout of this.
start -> JMS to somebody that does work? (a workflow?) -> recv task -> timeout -> go back to START or END?
Execution execution = runtimeService.createExecutionQuery().processInstanceId(piId).activityId(activityId).singleResult();
if (execution != null) {
runtimeService.signal(execution.getId());
} else {
// silently ignore this, or log something since either there was no execution in this state because it moved on, or a wrong combination of piId and activityId were passed on
}
If you put this in an mdb, or in a simple java class that gets WS or Rest annotations or even a simple file poller, you 'effectively' created the 'corresponding' receive tasks.07-28-2011 09:13 PM
07-29-2011 04:37 AM
sorry and thank you for your help (i'm over in NY, GMT -5),GMT+2 here if you take DST into account.
this is very close to what i am looking for; (and have mostly re-implemented via JMS in a fairly large hack)…So you see, there are other solutions 😉
but do have a few questions (none of which need to be answered soon):No problem, lets stay in the flow now
if the other workflow / service task is not active, it will have to actually be invoked (since jms just sends messages) (or does it have to be invoked once and start in a recv task state?)Do not think in workflow/service tasks for this. Think in 'something' needs to be done. JMS indeed just sends messages, but there is an MDB that receives the messages. This would normally do the work and what work is dependent on what you implement there. You can make a generic mdb that starts a workflow, based on information IN the message, or just runs some javacode (sleep() ;-)) Nothing fancy.
the recv task, since it is just a wait state that can be continued via recving a message, how can it be changed to obtain return values through the message.There is this great documentation thing (userguide apidocs) and examples etc…
I would much rather use this model above the one that I currently have, the receive task is much clearer than how I have implemented the JMS kludge.I know 😉
07-29-2011 05:45 AM
07-29-2011 09:46 AM
runtimeService.signal(execution.getId());
int count = Integer.parseInt((String) exec.getVariable("inputVar"));
System.err.println(""+count);
exec.setVaraible("inputVar", ""+(count+1));
Thread.sleep(250);
07-29-2011 11:26 AM
or am i just wrong and i can pass things via;
execution.setVariable() etc.
i would prefer to only have to MDB out, and use the signal() method to return back to the WF.I do not get what you mean by this…
the above simply fails to work properly.But what does it do? stay in the receive task? Blow up? Solve world hunger 😉
07-29-2011 11:38 AM
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns
mgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns
mgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="Breaker_Process" name="Breaker_Process">
<documentation>Place documentation for the 'Breaker' process here.</documentation>
<startEvent id="startevent1" name="Start"></startEvent>
<serviceTask id="servicetask1" name="SimplePrint" activiti:class="breakers.SimplePrint"></serviceTask>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway" default="flow3"></exclusiveGateway>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" name="START" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow3" name="LOOP" sourceRef="exclusivegateway1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow4" name="END" sourceRef="exclusivegateway1" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${inputVar==""}]]></conditionExpression>
</sequenceFlow>
<receiveTask id="receivetask1" name="Receive Task"></receiveTask>
<sequenceFlow id="flow5" name="" sourceRef="servicetask1" targetRef="receivetask1"></sequenceFlow>
<sequenceFlow id="flow6" name="NEVER TAKEN" sourceRef="receivetask1" targetRef="exclusivegateway1"></sequenceFlow>
<boundaryEvent id="boundarytimer1" name="" cancelActivity="true" attachedToRef="receivetask1">
<timerEventDefinition>
<timeDuration>PT5S</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow7" name="PT5S TIMEOUT" sourceRef="boundarytimer1" targetRef="exclusivegateway1"></sequenceFlow>
</process>
</definitions>
07-29-2011 12:40 PM
maybe this is the issue; when a recv task is hit, and this is run in eclipse, does the process simply end? or will it hang there?
07-29-2011 04:01 PM
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.