JBPM Timer Problem
avivstav May 2, 2007 11:54 AMHi
I try to creater simple flow including Timer:
<process-definition name="testprocess3"> <start-state name='start'> <transition to='wait' /> </start-state> <state name='wait'> <timer name='reminder' duedate='5 seconds' repeat='5 seconds' transition='time out'> <action class=MyActionHandler' /> </timer> <transition to='wait2'/> </state> <state name='wait2'> <transition to='end'/> </state> <end-state name='end' /> </process-definition>
And run it from My Test class as follows:
public void processTimer() { JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try { GraphSession graphSession = jbpmContext.getGraphSession(); ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("testprocess3"); ProcessInstance processInstance = new ProcessInstance(processDefinition); Token token = processInstance.getRootToken(); assertEquals("start", token.getNode().getName()); token.signal(); token.signal(); } finally { jbpmContext.close(); } }
The action class is implemented as follows:
public class MyActionHandler implements ActionHandler { public void execute(ExecutionContext executionContext) { System.out.println("Inside Action handler..."); } }
The first signal() advance from start to wait state which suppose to activate the Timer task every 5 seconds and run the Action class
It looks the Timer is never activated at all.
Any Idea why?
How exactlly Timers works, is it forked from the main process?
I add to jbpm.cfg.xml the following entries:
<jbpm-configuration> <jbpm-context> <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" /> <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" /> <service name="tx" factory="org.jbpm.tx.TxServiceFactory"/> <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" /> <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" /> <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" /> </jbpm-context> <!--configuration resource files pointing to default configuration files in jbpm-{version}.jar --> <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" /> <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" /> <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" /> <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" /> <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" /> <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" /> <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" /> <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" /> <long name="jbpm.msg.wait.timout" value="5000" singleton="true" /> <int name="jbpm.byte.block.size" value="1024" singleton="true" /> <string name="mail.smtp.host" value="localhost" /> <bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" /> <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" /> <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" /> <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor" singelton="true" /> </jbpm-configuration>