[JBoss jBPM] - Re: fork and join childeren
by tbeernot
"salaboy21" wrote : First of all, great ASCII graphic!!
|
Ah well ;-)
I'm building up unit test to slow work jbpm into my application. This is the one where I'm trying out parallel flows. I have written the output as comment next to the println's.
| /**
| */
| @Test
| public void test()
| {
| // Declare a process with a fork
| // S
| // |
| // F
| // / \
| // s1 s2
| // \ /
| // J
| // |
| // E
| ProcessDefinition lProcessDefinition = ProcessDefinition.parseXmlString(
| "<process-definition>" +
| " <start-state name=\"start\">" +
| " <transition to=\"fork1\"></transition>" +
| " </start-state>" +
| " <fork name=\"fork1\">" +
| " <transition to=\"state1\"></transition>" +
| " <transition to=\"state2\"></transition>" +
| " </fork>" +
| " <state name=\"state1\">" +
| " <transition to=\"join1\"></transition>" +
| " </state>" +
| " <state name=\"state2\">" +
| " <transition to=\"join1\"></transition>" +
| " </state>" +
| " <join name=\"join1\">" +
| " <transition to=\"end\"></transition>" +
| " </join>" +
| " <end-state name=\"end\"></end-state>" +
| "</process-definition>"
| );
|
| // Start a process
| ProcessInstance lProcessInstance = new ProcessInstance(lProcessDefinition);
|
| // Get the token
| Token lToken = lProcessInstance.getRootToken();
| System.out.println(lToken.getNode() + "/" + lToken.getChildren()); // start
| if (lToken.getChildren() != null) System.out.println( " -" + ((Token)lToken.getChildren().get(lToken.getChildren().keySet().iterator().next())).getNode() );
|
| // Goto the next
| lToken.signal();
| System.out.println(lToken.getNode() + "/" + lToken.getChildren()); // fork1
| if (lToken.getChildren() != null) System.out.println( " -" + ((Token)lToken.getChildren().get(lToken.getChildren().keySet().iterator().next())).getNode() );
|
| // Goto the next
| lToken.signal();
| System.out.println(lToken.getNode() + "/" + lToken.getChildren()); // state1
| if (lToken.getChildren() != null) System.out.println( " -" + ((Token)lToken.getChildren().get(lToken.getChildren().keySet().iterator().next())).getNode() );
|
| //Goto the next
| lToken.signal();
| System.out.println(lToken.getNode() + "/" + lToken.getChildren()); // join1
| if (lToken.getChildren() != null) System.out.println( " -" + ((Token)lToken.getChildren().get(lToken.getChildren().keySet().iterator().next())).getNode() );
|
| //Goto the next
| lToken.signal();
| System.out.println(lToken.getNode() + "/" + lToken.getChildren()); // end
| if (lToken.getChildren() != null) System.out.println( " -" + ((Token)lToken.getChildren().get(lToken.getChildren().keySet().iterator().next())).getNode() );
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4189135#4189135
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4189135
17 years, 4 months
[JBoss jBPM] - fork and join childeren
by tbeernot
The 3.2.3 documentation says: "When the root execution path is forked into multiple concurrent execution paths, the root is the parent and the newly created execution paths are all children of the root."
So if I have this flow:
| S
| |
| F
| / \
| s1 s2
| \ /
| J
| |
| E
|
The when the signal comes on the start node, it moves to the fork (F). It should then fork two childeren and then move forward to the join (J) and wait for the two childeren to reach the J as well.
However, if I write out the active node from the parent's token I see this:
1. StartState(start)
2. Fork(fork1)
3. State(state1)
4. Join(join1)
5. EndState
As soon as the token enters 'fork1', it does get 1 child. The getChilderen returns another token which is in state1 immediately. Then the parent token can be moved forward through state1 and the join, all the way to the end state.
The documentation states: "This way, implementation of a join can become straightforward: the implementation of the join just has to verify if all sibling-execution-paths are already positioned in the join node. If that is the case, the parent execution path can resume execution leaving the join node."
However I can move the parent token all the way to the end node, without ever signalling its childeren.
1. I do not understand where the two childeren are when the fork is done.
2. I do not understand why the parent remains in the fork instead of jumping to the join.
3. I do not understand how I can move the parent token past the join.
Something it not matching up.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4189127#4189127
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4189127
17 years, 4 months
[JBoss jBPM] - Re: How can i get inform about running tokens/processes.
by exe
I think I solved my problem. The problem was i misunderstood the bpm concept. I don't want to steal your time but I explain my problem maybe it can help for somebody.
I explain the bussines logic of my bpm:
We have some bussines function implamented as a stateless session bean.
I'll develop a custom action for every ejb invoke i call this node type with ejbInvoke node. The node invoke the EJB and if the invoke is succes signaling the Token to jump the next node.
I dont want to implement indentity I'll delegate the authorization information for the ejb layer. When somebody wants to start a process send a message with ProcessDef and his Identity.
The MessageDriven bean is listening on the queue. when a message received the MDB create a jbpmContext put the USER object into the jbpmContext and starts the process. Every "ejbInvoke" node call an ejb method with an USER in the parameter list (gets from the process context). If the EJB invocation falls with security exception the EjbInvoke node will not resume the execution (now our process is in waiting state on the EjbInvoke node) save the process instance and the MDB will be destroyed.
A different user can get a list with the processes wich are in waiting state and he can resume the process with his own USER objects. (send a message to the mdb with the USER objects and process id. The mdb will overwrite the user in the process Context with the the new USEER object and resume the process ).
If the B user tries to resume the process wich is already resumed by user A but the new state isn't persisted because the node isn't finished. The A user's mdb will get a Hibernate exception.
Now I think i found a solutions: The user cannot signaling directly the process execution. When i catch the security exception i insert a "resume process 112" task. The users can get only the task lists not the process instance list and he can complete the task with a resume message, when the user sends a resume message i set the task to complete persist the task state and AFTER resume the process execution from the custome task action. When the b user tries to complete the "resume process 112" he will get a message "the process already started" and a task will disappear from his tasklist because somebody else set to complete the task.
thx,
Janos
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4189084#4189084
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4189084
17 years, 4 months