Cancel a process in a repeated action
vbub Jul 2, 2007 6:54 AMi'm starting the execution of an action 5 seconds after entering a task node. this action repeatedly checks a state in a third party application and eventually shall cancel the whole process instance.
i'm trying to do this by using this code:
CancelProcessInstanceCommand cpic = new CancelProcessInstanceCommand(task.getProcessInstance().getId()); cpic.setCancelSubProcesses(true); CommandServiceImpl csi = new CommandServiceImpl(jbpmConfiguration); csi.execute(cpic);
i get the following error (running with postgreSQL on apache tomcat):
12:38:46,520 ERROR [168.0.18:1] JobExecutorThread : exception in job executor thread. waiting 2500 milliseconds org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: hibernate commit failed} at org.jbpm.svc.Services.close(Services.java:235) at org.jbpm.JbpmContext.close(JbpmContext.java:139) at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:181) at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:62) Caused by: org.jbpm.persistence.JbpmPersistenceException: hibernate commit failed at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:216) at org.jbpm.svc.Services.close(Services.java:222) ... 3 more Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.job.Timer#683] at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607) at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:253) at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:211) ... 4 more
i've read about the concept of executing the commands asynchronously but it seems the CommandServiceImpl executes the CancelProcessInstanceCommand immediately (when my action, called out of the JobExecutor/Timer is still active)... i'm not sure how to solve this and haven't found a thread or solution in this forum yet that seem to fit my problem. thank you very much, volker