[jboss-user] [jBPM] - JBPM 4.3: Is it possible to leave current state on timer listener?

Nugroho Saputro do-not-reply at jboss.com
Mon Apr 12 00:45:56 EDT 2010


Nugroho Saputro [http://community.jboss.org/people/nsaputro] created the discussion

"JBPM 4.3: Is it possible to leave current state on timer listener?"

To view the discussion, visit: http://community.jboss.org/message/536790#536790

--------------------------------------------------------------
Hi All,
 
 
Please help me, I am newbie at JBPM 4.x. I have a problem with leaving a state programmatically in timer listener. I always get exception like this:
 


12 Apr 2010 11:21:11 ERROR org.jbpm.pvm.internal.cmd.ExecuteJobCmd  - exception while executing 'timer[30|2010-04-12 11:21:11,412|timeout]'
org.jbpm.api.JbpmException: execution[ADSLProvisioning.22] is not active: inactive-scope
     at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1024)
     at org.jbpm.pvm.internal.model.ExecutionImpl.take(ExecutionImpl.java:466)
     at org.jbpm.pvm.internal.model.ExecutionImpl.takeDefaultTransition(ExecutionImpl.java:449)
     at uk.co.upshot.jbpm.handler.OrderStatusChecker.notify(OrderStatusChecker.java:62)
     at org.jbpm.pvm.internal.wire.usercode.UserCodeEventListener.notify(UserCodeEventListener.java:39)



What I would like to do is checking status from database repeatedly every X minutes. When it found certain status e.g. COMPLETED it should go to the next state, otherwise it will repeat until that status is reached. 
 
Currently I implement it as a state with a repeated timer:
 

<state name="Check Order Status">
  <on event="timeout">
    <timer duedate="10 minutes" repeat="10 minutes"></timer>
    <event-listener expr="#{OrderStatusChecker}"></event-listener>
  </on>
  <transition name="to-status-decision" to="status-decision"></transition>
</state>



and on the timer listener:

public class OrderStatusChecker implements EventListener {
 
    public void notify(EventListenerExecution event) throws Exception {        
        // Check status.
        String status = ...... get status from Database ...
        event.getProcessInstance().setVariable("status", status);
        
        if (status.equals("COMPLETED")) {
            // Leave current state
            ActivityExecution execution = (ActivityExecution) event.getParent();
            execution.takeDefaultTransition();
        }                
    }
}




Is it possible to do that in JBPM?  If it's not possible, is there any workaround for my case?

I use JBPM4.3 with spring 2.5.

Thank you.

Regards,
Nugroho

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/536790#536790]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100412/2ecbbcae/attachment.html 


More information about the jboss-user mailing list