You mean to clean the orphans ? OK. But how to correctly create a new entries ?
I found, that the transaction must be commited after the ProcessInstance has
been signaled, e.g. in the example above:
// ...init code
| ProcessInstance pInst = ctx.newProcessInstance("test1");
| pInst.signal();
| ctx.getSession().getTransaction().commit();
| // ... some other code. Now, the threads of the JobExecutor are able to
find the timer, and run it, but the transaction now is commited, which leads to
the following problems:
Let's assume now, a more complicated flow:<?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="urn:jbpm.org:jpdl-3.2" name="test1">
| <start-state name="start-state1">
| <transition to="state1" name="to_state1"></transition>
| </start-state>
| <state name="state1">
| <timer duedate="2 seconds" name="first_timer" repeat="2
seconds">
| <action class="test1.TimerActionHandler"></action>
| </timer>
| <transition to="state2" name="to_state2"></transition>
| <!-- <transition to="state1" name="to_state1"></transition> -->
| </state>
|
| <state name="state2">
| <timer duedate="5 seconds" name="second_timer" repeat="2
seconds">
| <action class="test1.TimerActionHandler"></action>
| </timer>
| <transition to="end-state1" name="to_end"></transition>
| </state>
|
|
| <end-state name="end-state1"></end-state>
| </process-definition>Now we have two timers, needed to start one after
another. The first_timer stops, the second_timer starts. Let's see the code://
...init code
| ProcessInstance pInst = ctx.newProcessInstance("test1");
| pInst.signal();
| ctx.getSession().getTransaction().commit();
| System.in.read(); // we're just waiting for the enter....the first_timer is
running
| pInst.signal(); // we move to the next node....in the hope of stopping
first and starting second
| System.in.read(); // ...but nothing happens
| //....
OK, adding one more commit, e.g:pInst.signal();
| ctx.getSession().getTransaction().commit();
| System.in.read();
| pInst.signal();
| ctx.getSession().getTransaction().commit();
| System.in.read();leads to the TransactionException, which is pretty
obvious:org.hibernate.TransactionException: Transaction not successfully started
| at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:100)
| at Test2.main(Test2.java:41)
Beginning a new transaction, however, raises the StaleObjectStateException: //
....
| ProcessInstance pInst = ctx.newProcessInstance("test1");
|
| pInst.signal();
| ctx.getSession().getTransaction().commit();
| System.in.read();
| ctx.getSession().getTransaction().begin();
| pInst.signal();
| ctx.getSession().getTransaction().commit();
| System.in.read();
| //....
13:36:40,736 [main] ERROR AbstractFlushingEventListener : Could not synchronize
database state with session
| org.hibernate.StaleObjectStateException: Row was updated or deleted by
another transaction (or unsaved-value mapping was incorrect):
[org.jbpm.graph.exe.Token#3601]
| at
org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
which is probably realted to the fact, that the JobExecutor is still running in
the background and locking the table with the long transaction (I guess).
So the question remains: how the process definitions with timers should be
deployed without the jbpm-console, to run as they should ?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066396#4066396
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066396
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user