-
1. Re:
koen.aers Feb 14, 2006 4:30 AM (in response to boerse)Have a look at the section of the docs on timers : http://docs.jboss.com/jbpm/v3/userguide/scheduler.html#timers
Regards,
Koen -
2. Re:
boerse Feb 14, 2006 5:07 PM (in response to boerse)Hi Koen, thank you for the response, i've already read the docs but what i want to do is:
order-> task node (accept/cancel order)-> end
it's quite simple, if in a fixed period i don't accept or cancel explicity the order, it will be automatically executed and the system ends. I tried to make it in jbpm but when the timer starts, in the java:package org.jbpm.example; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jbpm.context.exe.ContextInstance; import org.jbpm.graph.def.ActionHandler; import org.jbpm.graph.exe.ExecutionContext; import org.jbpm.taskmgmt.def.Swimlane; import org.jbpm.taskmgmt.def.TaskMgmtDefinition; import org.jbpm.taskmgmt.exe.SwimlaneInstance; import org.jbpm.taskmgmt.exe.TaskMgmtInstance; public class timeOut implements ActionHandler { private static final long serialVersionUID = 1L; String swimlaneName; String msg; public void execute(ExecutionContext executionContext) throws Exception { TaskMgmtDefinition taskMgmtDefinition = executionContext.getProcessDefinition().getTaskMgmtDefinition(); TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance(); ContextInstance contextInstance = executionContext.getContextInstance(); Swimlane shipperSwimlane = taskMgmtDefinition.getSwimlane("user"); SwimlaneInstance shipperSwimlaneInstance = taskMgmtInstance.getInitializedSwimlaneInstance(executionContext, shipperSwimlane); String actorId = shipperSwimlaneInstance.getActorId(); String displayMsg = "a";//replace(msg, "${"+swimlaneName+"}", actorId); //displayMsg = replace(displayMsg, "${item}", (String)contextInstance.getVariable("item")); //displayMsg = replace(displayMsg, "${date}", (String)contextInstance.getVariable("date")); log.info("###############################################"); log.info("### TimeOut: "+displayMsg); log.info("###############################################"); executionContext.leaveNode(); } static String replace(String msg, String pattern, String replacement) { String replaced = null; int pos = msg.indexOf(pattern); if (pos!=-1) { replaced = msg.substring(0,pos) +replacement +msg.substring(pos+pattern.length()); } return replaced; } private static final Log log = LogFactory.getLog(timeOut.class); }
it leaves the node but informs of an error:23:04:40,339 INFO [timeOut] ##################################### ########## 23:04:40,349 WARN [Timer] timer action threw exception org.jbpm.graph.def.DelegationException at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:349) at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<g enerated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.ProcessDefinition$$EnhancerByCGLIB$$131c30ea.raise Exception(<generated>) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:343) at org.jbpm.graph.def.Node.execute(Node.java:332) at org.jbpm.graph.def.Node.enter(Node.java:316) at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated >) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$c68a987a.enter(<generated>) at org.jbpm.graph.def.Transition.take(Transition.java:119) at org.jbpm.graph.def.Node.leave(Node.java:382) at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:198) at org.jbpm.graph.def.Node.leave(Node.java:346) at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated >) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$9d2b2f44.leave(<genera ted>) at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:1 20) at org.jbpm.example.timeout.execute(timeout.java:25) at org.jbpm.graph.def.Action.execute(Action.java:123) at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generat ed>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$c66c9cae.execute(<generat ed>) at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84) at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread .java:118) at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70) Caused by: org.jbpm.JbpmException: can't leave node 'Node(auto-out)' without leaving transition at org.jbpm.graph.def.Node.leave(Node.java:364) at org.jbpm.graph.def.Node.leave(Node.java:346) at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:1 20) at org.jbpm.example.timeOut.execute(pedidoRecibidoTime Out.java:38) at org.jbpm.graph.def.Action.execute(Action.java:123) at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generat ed>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$c66c9cae.execute(<generat ed>) at org.jbpm.graph.def.Node.execute(Node.java:328) ... 23 more
the cause seems to be:
Caused by: org.jbpm.JbpmException: can't leave node 'Node(auto-out)'
without leaving transition
i don't understand it... should be this done in a differente way? any help will be very appreciated... -
3. Re:
koen.aers Feb 15, 2006 5:52 AM (in response to boerse)You should signal the token instead of calling leaveNode.
Regards,
Koen -
-
5. Re:
boerse Feb 15, 2006 7:47 AM (in response to boerse)I changed the code to make a signal, but the problem persists:
it leaves the node but the error is still here:13:41:05,209 DEBUG [GraphElement] event 'node-leave' on 'Node(pedido recibido au to)' for 'Token(/)' 13:41:05,219 DEBUG [GraphElement] event 'transition' on 'Transition(Terminar)' f or 'Token(/)' 13:41:05,229 DEBUG [GraphElement] event 'node-enter' on 'EndState(fin del proces o)' for 'Token(/)' 13:41:05,239 DEBUG [GraphElement] event 'process-end' on 'ProcessDefinition(exam ple)' for 'Token(/)' 13:41:05,259 DEBUG [GraphElement] event 'after-signal' on 'TaskNode(cursar pedid o)' for 'Token(/)' 13:41:05,269 DEBUG [Services] executing default save operations 13:41:08,433 DEBUG [StaticNotifier] woke up 13:41:50,324 DEBUG [JbpmContextInfo] creating jbpm context with service factorie s '[message, scheduler, logging, persistence, authentication]' 13:41:50,324 DEBUG [HibernateSaveOperation] saving process instance 13:41:50,334 DEBUG [SaveLogsOperation] flushing logs to logging service. 13:41:50,354 DEBUG [CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe. ProcessInstance@1a32902' 13:41:50,354 DEBUG [SchedulerThread] deleting timer 'timer(autoconf,org.j bpm.example.timeout,13:41:04,978)' 13:41:50,374 DEBUG [JbpmContext] closing JbpmContext 13:41:50,374 DEBUG [Services] closing service 'persistence': org.jbpm.persistenc e.db.DbPersistenceService@2c1b13 13:41:50,384 DEBUG [DbPersistenceService] committing hibernate transaction 13:41:50,394 DEBUG [JbpmContext] creating JbpmContext 13:41:50,394 DEBUG [DbPersistenceServiceFactory] creating persistence service 13:41:50,394 DEBUG [DbPersistenceService] creating hibernate session 13:41:50,404 DEBUG [DbPersistenceService] beginning hibernate transaction 13:41:50,404 DEBUG [JbpmContext] closing JbpmContext 13:41:50,414 DEBUG [Services] closing service 'persistence': org.jbpm.persistenc e.db.DbPersistenceService@de1cb6 13:41:50,414 DEBUG [DbPersistenceService] committing hibernate transaction 13:41:50,414 DEBUG [DbPersistenceService] closing hibernate session 13:41:50,424 DEBUG [Services] closing service 'message': org.jbpm.msg.db.DbMessa geService@2f06b6 13:41:50,424 DEBUG [CommandExecutorThread] waiting for more messages 13:41:50,434 DEBUG [StaticNotifier] going to wait for (CMD_EXECUTOR, java.lang.O bject@f08d0f) 13:41:50,454 ERROR [AbstractBatcher] Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count fr om update: 0 actual row count: 0 expected: 1 at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java :93) at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.jav a:79) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav a:58) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java: 193) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio ns(AbstractFlushingEventListener.java:296) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus hEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java :106) at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceServi ce.java:161) at org.jbpm.svc.Services.close(Services.java:211) at org.jbpm.JbpmContext.close(JbpmContext.java:138) at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread .java:161) at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70) 13:41:50,554 ERROR [AbstractFlushingEventListener] Could not synchronize databas e state with session org.hibernate.StaleStateException: Batch update returned unexpected row count fr om update: 0 actual row count: 0 expected: 1 at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java :93) at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.jav a:79) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav a:58) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java: 193) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio ns(AbstractFlushingEventListener.java:296) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus hEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java :106) at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceServi ce.java:161) at org.jbpm.svc.Services.close(Services.java:211) at org.jbpm.JbpmContext.close(JbpmContext.java:138) at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread .java:161) at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70) 13:41:55,441 DEBUG [StaticNotifier] woke up 13:42:30,341 DEBUG [JbpmContextInfo] creating jbpm context with service factorie s '[message, scheduler, logging, persistence, authentication]' 13:42:30,351 DEBUG [JbpmContext] creating JbpmContext 13:42:30,351 DEBUG [DbPersistenceServiceFactory] creating persistence service 13:42:30,361 DEBUG [DbPersistenceService] creating hibernate session 13:42:30,361 INFO [STDOUT] org.jbpm.persistence.JbpmPersistenceException: could n't commit hibernate session 13:42:30,371 INFO [STDOUT] at org.jbpm.persistence.db.DbPersistenceService. close(DbPersistenceService.java:171) 13:42:30,381 INFO [STDOUT] at org.jbpm.svc.Services.close(Services.java:211 ) 13:42:30,381 INFO [STDOUT] at org.jbpm.JbpmContext.close(JbpmContext.java:1 38) 13:42:30,391 INFO [STDOUT] at org.jbpm.scheduler.impl.SchedulerThread.execu teTimers(SchedulerThread.java:161) 13:42:30,391 INFO [STDOUT] at org.jbpm.scheduler.impl.SchedulerThread.run(S chedulerThread.java:70) 13:42:30,401 INFO [STDOUT] Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected : 1 13:42:30,411 INFO [STDOUT] at org.hibernate.jdbc.BatchingBatcher.checkRowCo unt(BatchingBatcher.java:93) 13:42:30,411 INFO [STDOUT] at org.hibernate.jdbc.BatchingBatcher.checkRowCo
my new action is:import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jbpm.graph.def.ActionHandler; import org.jbpm.graph.exe.ExecutionContext; import org.jbpm.graph.exe.Token; public class timeout implements ActionHandler { private static final long serialVersionUID = 1L; String swimlaneName; public void execute(ExecutionContext executionContext) throws Exception { String actorId = "1";//executionContext.getTaskMgmtInstance() // .getSwimlaneInstance(swimlaneName) // .getActorId(); String taskName = executionContext.getTaskInstance().getName(); log.info //executionContext.leaveNode(); //ProcessInstance processInstance = new ProcessInstance(); Token token = executionContext.getToken(); token.signal(); } private static final Log log = LogFactory.getLog(timeout.class); }
any idea? Thanks... -
6. Re:
koen.aers Feb 15, 2006 9:05 AM (in response to boerse)It looks like the timer thread wants to execute a timer which is void because the process is finished. Make sure to cancel any timers in this action resulting in the ending of the process.
Regards,
Koen -
-
8. Re:
boerse Feb 15, 2006 11:14 AM (in response to boerse)Ok, done with a cancel-timer, BUT (immer a but) i do spring to the next node and end the process, BUT an action to be made in the temporized is still in the tasks to be performed by the assigned actor. Of course i want to abort all tasks related with this (already ended) process...
-
9. Re:
boerse Feb 16, 2006 4:27 AM (in response to boerse)Hi, i'm still working arround this point. I have a task-node with several tasks. How can i do to cancel all tasks when the first of them is finished? I make a token.signal (or alternatetively TaskInstance ti= executionContext.getTaskInstance(); ti.end();, but the other tasks pending from that task-node are still active. I tried with create-tasks="true" signal="first" and so but no result... Thanks!
-
10. Re:
boerse Feb 16, 2006 8:07 AM (in response to boerse)Hi, i think the only way to end all tasks from the task-node is to kill them (or cancel them) in the action of the timer.
I added the code:TaskInstance ti= executionContext.getTaskInstance(); //ti.end(); Collection tasks = executionContext.getTaskMgmtInstance().getUnfinishedTasks(token); Iterator taskItr = tasks.iterator(); while(taskItr.hasNext()) { TaskInstance ti2 = (TaskInstance)taskItr.next(); if (ti2!=ti) {if(!ti2.hasEnded()) ti2.cancel();} {ti.end();}
So it should cancel the other task of the node (there are 2, timer and the other task that waits for the user's action) and end the timer one, but althought all processes are "propery" ended, it informs of an error:14:02:27,758 DEBUG [TaskInstance] completion of task 'send_order' results in taking the default transition 14:02:27,768 WARN [Timer] timer action threw exception org.jbpm.JbpmException: couldn't signal token 'Token(/)' : node 'EndState(end_state)' doesn't have a default transition at org.jbpm.graph.exe.Token.signal(Token.java:121) at org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generate d>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$5810960d.signal(<generated >) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:408) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:322) at org.jbpm.taskmgmt.exe.TaskInstance.cancel(TaskInstance.java:313) at org.jbpm.combustible.timeout.execute(timeout.java:57) at org.jbpm.graph.def.Action.execute(Action.java:123) at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generat ed>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$c72232ad.execute(<generat ed>) at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84) at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread .java:118) at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70) 14:02:27,848 ERROR [Timer] unhandled timer exception org.jbpm.graph.def.DelegationException at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:349) at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<g enerated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.ProcessDefinition$$EnhancerByCGLIB$$13d1c6e9.raise Exception(<generated>) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:343) at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<g enerated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$9de0c543.raiseExceptio n(<generated>) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:343) at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<g enerated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.taskmgmt.def.Task$$EnhancerByCGLIB$$a6c2cb06.raiseException( <generated>) at org.jbpm.scheduler.exe.Timer.execute(Timer.java:94) at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread .java:118) at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70) Caused by: org.jbpm.JbpmException: couldn't signal token 'Token(/)' : node 'EndS tate(end_state)' doesn't have a default transition at org.jbpm.graph.exe.Token.signal(Token.java:121) at org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generate d>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$5810960d.signal(<generated >) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:408) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:322) at org.jbpm.taskmgmt.exe.TaskInstance.cancel(TaskInstance.java:313) at org.jbpm.combustible.timeout.execute(timeout.java:57) at org.jbpm.graph.def.Action.execute(Action.java:123) at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generat ed>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ er.java:136) at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$c72232ad.execute(<generat ed>) at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84) ... 2 more
It seems that by doing cancel or end the token goes to the next node (end) and in the cancellation or ending of the other task it tries again to move forward the token... i don't know what else to try. :( -
11. Re:
boerse Feb 16, 2006 11:37 AM (in response to boerse)Hi, i'm still on it and i tell you the news (for those who'll use it in the future):
i had 2 tasks in one task-node, the one for the timer and the other waiting for the action of the user, if timer is over, i signal or end (i don't see anu difference) the instance and i lose the token, in order to be able to end (cancel) the other task, i have to set signal="last", problem is that the process does not end until timer ends. More or less it will do, but now i want to add a second user that can perform an action, too, so i added the timer-task some interaction (because i assignment expression previous--> group(mygroup) does not work), so what should i do now? set 2 timers in the 2 tasks of the task-node in order to cancel the non-realised-task? I'm pretty confused... Isn't there any easier way to break out from a task-node by a timer without having to make all those spins? -
12. Re:
camunda Nov 8, 2006 3:39 PM (in response to boerse)Hi all!
I have been a little bit quite the last months (because of a non jBPM project) but now I am back in development :-)
I stuck in a similar problem, are there any new ideas about that issue before I start investigating deeper?
Thanks a lot
Bernd -
13. Re:
tom.baeyens Nov 8, 2006 4:05 PM (in response to boerse)please report your analysis on the dev forum if you think that jbpm should change in one way or another
-
14. Re:
kukeltje Nov 8, 2006 4:06 PM (in response to boerse)Bernd,
Issues regarding cancelling timers, open tasks etc when a process ends is at least addressed in 3.2 (cvs) and it might be addressed in 3.1.2/3 as well. Not sure about the latter. Check jira for this.
If your problem is different/not solved, please open a new topic for this