Timer Question
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2014 05:13 PM
I am new to Activiti so forgive me if this is a stupid question
I am creating an encoding workflow so after I send a request to do encoding I need to check the status periodically and based on the status I need to either move to the next step in the workflow or terminate the workflow . How can I achieve this in Activiti . I have been using JBPM where I do the following to achieve the above functionality but not sure how can i do the same in Activiti
<state name="Wait for Callback">
<timer name="Wait for Callback Action" duedate="15 minutes"
repeat="10 minute">
<action
class='com.mtvi.mediabus.egvtranscode.action.MediaSiloUXStatusTimerAction' />
</timer>
<transition to="Download Files" name="Download_Files"></transition>
<transition to="exception" name="exception"></transition>
</state>
Can someone help me with this ?
I am creating an encoding workflow so after I send a request to do encoding I need to check the status periodically and based on the status I need to either move to the next step in the workflow or terminate the workflow . How can I achieve this in Activiti . I have been using JBPM where I do the following to achieve the above functionality but not sure how can i do the same in Activiti
<state name="Wait for Callback">
<timer name="Wait for Callback Action" duedate="15 minutes"
repeat="10 minute">
<action
class='com.mtvi.mediabus.egvtranscode.action.MediaSiloUXStatusTimerAction' />
</timer>
<transition to="Download Files" name="Download_Files"></transition>
<transition to="exception" name="exception"></transition>
</state>
Can someone help me with this ?
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2014 01:29 AM
Hi,
You could use timer intermediate event in the loop
http://www.activiti.org/userguide/#bpmnTimerIntermediateEvent
Regards
Martin
You could use timer intermediate event in the loop
http://www.activiti.org/userguide/#bpmnTimerIntermediateEvent
Regards
Martin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2014 11:14 AM
Hi martin , Thanks for the reply . I am already using intermediateCatchEvent but i am not sure how to signal it to the next step in the process after the desired status is received ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2014 06:03 PM
Attaching the bpmn file for reference
Code
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import com.mtvi.unicorn.bean.TestBean;
public class CheckStatus implements ActivityBehavior {
public void execute(ActivityExecution execution) throws Exception {
TestBean ts = (TestBean) execution.getVariable("testBean");
System.out.println("I am here to check Status:" + ts.getId());
PvmTransition transition = null;
try {
int id = ts.getId();
if (id > 20) {
transition = execution.getActivity().findOutgoingTransition("flow6");
execution.take(transition);
} else {
id = id + 10;
ts.setId(id);
}
} catch (Exception e) {
transition = execution.getActivity().findOutgoingTransition("flow5");
execution.take(transition);
}
}
I am trying to transition to next node only if the condition is reached but the problem here is this class is called only once . I want this class to be called again and again till the condition is reached and it moves to the next node . Can someone help me with this
Code
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import com.mtvi.unicorn.bean.TestBean;
public class CheckStatus implements ActivityBehavior {
public void execute(ActivityExecution execution) throws Exception {
TestBean ts = (TestBean) execution.getVariable("testBean");
System.out.println("I am here to check Status:" + ts.getId());
PvmTransition transition = null;
try {
int id = ts.getId();
if (id > 20) {
transition = execution.getActivity().findOutgoingTransition("flow6");
execution.take(transition);
} else {
id = id + 10;
ts.setId(id);
}
} catch (Exception e) {
transition = execution.getActivity().findOutgoingTransition("flow5");
execution.take(transition);
}
}
I am trying to transition to next node only if the condition is reached but the problem here is this class is called only once . I want this class to be called again and again till the condition is reached and it moves to the next node . Can someone help me with this
test.bpmn20.txt.zip
2 KB

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2014 02:59 AM
The intermediate catch event doesn't fire again if the process instance reached an end state in the first cycle. Is that the case in your example?
Best regards,
Best regards,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2014 02:59 AM
Hi
- I would recommend to remove logic from java class into the process definition
- use exclusive gateway (http://www.activiti.org/userguide/#bpmnExclusiveGateway) to take decision whether continue in checking or continue further
- current implementation can consume a lot of resources in the loop. I would say you should use ReceiveTask (http://www.activiti.org/userguide/#bpmnReceiveTask) to wait
Regards
Martin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2014 04:34 PM
Thanks Martin . I am using exclusive gateway and I am able to transition from one task to another based on certain condition
I am still not clear about certain things
1) If I use ReceiveTask dont I need an external Trigger to take some action ?
2) In timer I want it to repeat checking the status every 1 min for n number of times
I gave the following in my bpm file
<timeCycle>R3/PT1M</timeCycle>
I thought the above expression means repeat 3 time every 1 minutes but I see it is checking status every sec .
I am still not clear about certain things
1) If I use ReceiveTask dont I need an external Trigger to take some action ?
2) In timer I want it to repeat checking the status every 1 min for n number of times
I gave the following in my bpm file
<timeCycle>R3/PT1M</timeCycle>
I thought the above expression means repeat 3 time every 1 minutes but I see it is checking status every sec .
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2014 02:33 AM
1) If I use ReceiveTask dont I need an external Trigger to take some action ?Yes. Trigger signals process execution to continue.
2) In timer I want it to repeat checking the status every 1 min for n number of timesCould you prepare jUnit test for it?
http://forums.activiti.org/content/sticky-how-write-unit-test
Regards
Martin
