[JBoss jBPM] - Parallel Review Process: template process definition
by alf_dave
I believe the jBPM community can greatly benefit from a library of demo/template process definitions for common workflows.
The current code samples, docs & references to workflow patterns concentrate on the low level building blocks, but it requires a blind jump and effort to pull together the blocks into a coherent workflow.
So, to start, I'd like to put forward the following template definition for supporting a review & approve process where 'N' parallel reviewers can approve or reject. Approval is only reached when a specified percentage of the reviewers approve.
A custom 'ForEachFork' (modified from the contribution on the wiki) is used to implement the parallel part. The process variables 'reviewers' (a list) and 'required_approve_percent' need to be provided when starting the workflow.
Is there a better way?
Would it be useful to start a library of these on the WIKI?
Regards,
David Caruana
Alfresco
| <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="parallelreview">
|
| <swimlane name="initiator"></swimlane>
|
| <start-state name="start">
| <task name="submit" swimlane="initiator" />
| <transition name="" to="startreview">
| <script>
| <variable name="approve_count" access="write" />
| <expression>
| approve_count = 0;
| </expression>
| </script>
| </transition>
| </start-state>
|
| <node name="startreview">
| <action class="ForEachFork">
| <foreach>#{reviewers}</foreach>
| <var>reviewer</var>
| </action>
| <transition name="review" to="review" />
| </node>
|
| <task-node name="review">
| <task name="review">
| <event type="task-create">
| <script>
| taskInstance.actorId = reviewer;
| </script>
| </event>
| </task>
| <transition name="reject" to="endreview" />
| <transition name="approve" to="endreview">
| <script>
| <variable name="approve_count" access="read,write" />
| <expression>
| approve_count = approve_count +1;
| </expression>
| </script>
| </transition>
| </task-node>
|
| <join name="endreview">
| <transition to="isapproved" />
| </join>
|
| <decision name="isapproved">
| <event type="node-enter">
| <script>
| <variable name="approve_percent" access="write"/>
| <expression>
| approve_percent = ((approve_count * 100) / reviewers.size());
| </expression>
| </script>
| </event>
| <transition name="reject" to="rejected" />
| <transition name="approve" to="approved">
| <condition>#{approve_percent >= required_approve_percent}</condition>
| </transition>
| </decision>
|
| <task-node name="rejected">
| <task name="rejected" swimlane="initiator" />
| <transition to="end" />
| </task-node>
|
| <task-node name="approved">
| <task name="approved" swimlane="initiator" />
| <transition to="end" />
| </task-node>
|
| <end-state name="end"/>
|
| </process-definition>
|
The ForEachFork.java:
|
| import java.util.ArrayList;
| import java.util.Collection;
| import java.util.List;
|
| import org.dom4j.Element;
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.def.Node;
| import org.jbpm.graph.def.Transition;
| import org.jbpm.graph.exe.ExecutionContext;
| import org.jbpm.graph.exe.Token;
| import org.jbpm.instantiation.FieldInstantiator;
| import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
|
|
| /**
| * For each "item in collection", create a fork.
| */
| public class ForEachFork implements ActionHandler
| {
| private static final long serialVersionUID = 4643103713602441652L;
|
| private Element foreach;
| private String var;
|
|
| /**
| * Create a new child token for each item in list.
| *
| * @param executionContext
| * @throws Exception
| */
| @SuppressWarnings("unchecked")
| public void execute(final ExecutionContext executionContext)
| throws Exception
| {
| //
| // process action handler arguments
| //
|
| if (foreach == null)
| {
| throw new Exception("forEach has not been provided");
| }
|
| // build "for each" collection
| List forEachColl = null;
| String forEachCollStr = foreach.getTextTrim();
| if (forEachCollStr != null)
| {
| if (forEachCollStr.startsWith("#{"))
| {
| Object eval = JbpmExpressionEvaluator.evaluate(forEachCollStr, executionContext);
| if (eval == null)
| {
| throw new Exception("forEach expression '" + forEachCollStr + "' evaluates to null");
| }
|
| // expression evaluates to string
| if (eval instanceof String)
| {
| String[] forEachStrs = ((String)eval).trim().split(",");
| forEachColl = new ArrayList(forEachStrs.length);
| for (String forEachStr : forEachStrs)
| {
| forEachColl.add(forEachStr);
| }
| }
|
| // expression evaluates to collection
| else if (eval instanceof Collection)
| {
| forEachColl = (List)eval;
| }
| }
| }
| else
| {
| forEachColl = (List)FieldInstantiator.getValue(List.class, foreach);
| }
|
| if (var == null || var.length() == 0)
| {
| throw new Exception("forEach variable name has not been provided");
| }
|
| //
| // create forked paths
| //
|
| Token rootToken = executionContext.getToken();
| Node node = executionContext.getNode();
| List<ForkedTransition> forkTransitions = new ArrayList<ForkedTransition>();
|
| // first, create a new token and execution context for each item in list
| for (int i = 0; i < node.getLeavingTransitions().size(); i++)
| {
| Transition transition = (Transition) node.getLeavingTransitions().get(i);
|
| for (int iVar = 0; iVar < forEachColl.size(); iVar++)
| {
| // create child token to represent new path
| String tokenName = getTokenName(rootToken, transition.getName(), iVar);
| Token loopToken = new Token(rootToken, tokenName);
| loopToken.setTerminationImplicit(true);
| executionContext.getJbpmContext().getSession().save(loopToken);
|
| // assign variable within path
| final ExecutionContext newExecutionContext = new ExecutionContext(loopToken);
| newExecutionContext.getContextInstance().createVariable(var, forEachColl.get(iVar), loopToken);
|
| // record path & transition
| ForkedTransition forkTransition = new ForkedTransition();
| forkTransition.executionContext = newExecutionContext;
| forkTransition.transition = transition;
| forkTransitions.add(forkTransition);
| }
| }
|
| //
| // let each new token leave the node.
| //
| for (ForkedTransition forkTransition : forkTransitions)
| {
| node.leave(forkTransition.executionContext, forkTransition.transition);
| }
| }
|
| /**
| * Create a token name
| *
| * @param parent
| * @param transitionName
| * @return
| */
| protected String getTokenName(Token parent, String transitionName, int loopIndex)
| {
| String tokenName = null;
| if (transitionName != null)
| {
| if (!parent.hasChild(transitionName))
| {
| tokenName = transitionName;
| }
| else
| {
| int i = 2;
| tokenName = transitionName + Integer.toString(i);
| while (parent.hasChild(tokenName))
| {
| i++;
| tokenName = transitionName + Integer.toString(i);
| }
| }
| }
| else
| {
| // no transition name
| int size = ( parent.getChildren()!=null ? parent.getChildren().size()+1 : 1 );
| tokenName = Integer.toString(size);
| }
| return tokenName + "." + loopIndex;
| }
|
| /**
| * Fork Transition
| */
| private class ForkedTransition
| {
| private ExecutionContext executionContext;
| private Transition transition;
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979150#3979150
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979150
19 years, 8 months
[JBoss and NetBeans] - jboss in one box and netbeans in another
by dietice
Hi, can someone help me to configure netbeans to use a jboss installation in another pc? when I run a project netbeans says:
...
dist:
pre-run-deploy:
Starting server JBoss Application Server 4
Starting JBoss Application Server 4
and in the jboss console it says:
===============================================================================
JBoss Bootstrap Environment
JBOSS_HOME: y:\bin\\..
JAVA: C:\java\jdk1.5.0_09\bin\java
JAVA_OPTS: -Dhttp.proxyHost=192.168.2.254 -Dhttp.proxyPort=3128 -Dhttp.nonProxyHosts="localhost|127.0.0.1|pcbanio" -Dhttps.proxyHost=192.168.2.254 -Dhttps.proxyPort=3128 -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
CLASSPATH: C:\java\jdk1.5.0_09\lib\tools.jar;y:\bin\\run.jar
===============================================================================
and it stays there!!!
Can someone give me some clue??
thanks and sorry about my english :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979149#3979149
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979149
19 years, 8 months
[JBoss Messaging] - BatchUpdateException in jms
by ap_nat
I am using jboss-4.0.4.GA with jboss-messaging-1.0.1.CR4 with oracle 10.1.0.2.0 as the message persistence store. If the PersistenceManager manager is configured for UsingBatchUpdates, it throws a
java.sql.BatchUpdateException: ORA-03106: fatal two-task communication protocol error
We are able to replicate this issue using one of the tests. This test tries sending a 12.0 kb message after some 65 smaller messages sent within a time span of 13 seconds on a Microsoft Windows XP [Version 5.1.2600] machine using jdk version 1.4.2_03. On other machines too this test causes this problem.
Though these steps do not guarantee this error, we are running into it consistently.
The complete stack trace is as follows:
| java.sql.BatchUpdateException: ORA-03106: fatal two-task communication protocol error
|
| at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
| at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8739)
| at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)
| at org.jboss.messaging.core.plugin.JDBCPersistenceManager.handleBeforePrepare(JDBCPersistenceManager.java:3406)
| at org.jboss.messaging.core.plugin.JDBCPersistenceManager$TransactionCallback.beforePrepare(JDBCPersistenceManager.java:4471)
| at org.jboss.messaging.core.tx.Transaction.prepare(Transaction.java:224)
| at org.jboss.jms.server.endpoint.ServerConnectionEndpoint.sendTransaction(ServerConnectionEndpoint.java:381)
| at org.jboss.jms.server.endpoint.advised.ConnectionAdvised.org$jboss$jms$server$endpoint$advised$ConnectionAdvised$sendTransaction$aop(ConnectionAdvised.java:99)
| at sun.reflect.GeneratedMethodAccessor135.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:324)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.jms.server.container.ServerLogInterceptor.invoke(ServerLogInterceptor.java:105)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aop.Advisor.dynamicInvoke(Advisor.java:723)
| at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:101)
| at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:126)
| at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:999)
| at org.jboss.remoting.transport.local.LocalClientInvoker.invoke(LocalClientInvoker.java:98)
| at org.jboss.remoting.Client.invoke(Client.java:612)
| at org.jboss.remoting.Client.invoke(Client.java:604)
| at org.jboss.jms.client.delegate.DelegateSupport.invoke(DelegateSupport.java:112)
| at org.jboss.jms.client.delegate.ClientConnectionDelegate$sendTransaction_N4986868250254447300.invokeNext(ClientConnectionDelegate$sendTransaction_N4986868250254447300.java)
| at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:134)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:117)
| at org.jboss.jms.client.delegate.ClientConnectionDelegate$sendTransaction_N4986868250254447300.invokeNext(ClientConnectionDelegate$sendTransaction_N4986868250254447300.java)
| at org.jboss.jms.client.container.ExceptionInterceptor.invoke(ExceptionInterceptor.java:69)
| at org.jboss.jms.client.delegate.ClientConnectionDelegate$sendTransaction_N4986868250254447300.invokeNext(ClientConnectionDelegate$sendTransaction_N4986868250254447300.java)
| at org.jboss.jms.client.container.ClientLogInterceptor.invoke(ClientLogInterceptor.java:107)
| at org.jboss.jms.client.delegate.ClientConnectionDelegate$sendTransaction_N4986868250254447300.invokeNext(ClientConnectionDelegate$sendTransaction_N4986868250254447300.java)
| at org.jboss.jms.client.delegate.ClientConnectionDelegate.sendTransaction(ClientConnectionDelegate.java)
| at org.jboss.jms.tx.ResourceManager.sendTransactionXA(ResourceManager.java:491)
| at org.jboss.jms.tx.ResourceManager.prepare(ResourceManager.java:379)
| at org.jboss.jms.tx.MessagingXAResource.prepare(MessagingXAResource.java:151)
| at org.jboss.tm.TransactionImpl$Resource.prepare(TransactionImpl.java:2212)
| at org.jboss.tm.TransactionImpl.prepareResources(TransactionImpl.java:1660)
| at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:347)
| at org.jboss.tm.TxManager.commit(TxManager.java:240)
| at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979143#3979143
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979143
19 years, 8 months
[JBoss jBPM] - Missing N.3.0.12-SNAPSHOT\org.jbpm.gd.jpdl.feature-3.0.12-SN
by clandestino_bgd
After I removed all invocations of docbook-support (in several build.xml files) I faced another error and I am afraid that I need your help urgently.
Here is the ant stacktrace.
Thank you for help.
Regards
Milan
prepare.workspace:
[mkdir] Created dir: D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\features
[mkdir] Created dir: D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\plugins
[copy] Copying 4 files to D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\features\org.jbpm.gd.jpdl.feature
[copy] Copying 85 files to D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\plugins\org.jbpm.gd.jpdl.core
[copy] Copying 265 files to D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\plugins\org.jbpm.gd.jpdl.ui
[copy] Copying 7 files to D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\plugins\org.jbpm.gd.jpdl.help
run-eclipse-plugin-builder:
[java] Buildfile: mainTargets.xml
[java] main:
[java] preBuild:
[java] preSetup:
[java] [echo] doing preSetup
[java] getMapFiles:
[java] [echo] doing getMapFiles
[java] [copy] Copying 1 file to D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\workspace\maps
[java] postSetup:
[java] [echo] doing postSetup
[java] fetch:
[java] generate:
[java] preGenerate:
[java] [echo] doing preGenerate
[java] [echo] baseLocation is d:/work/java/jbpm.3/eclipse
[java] allElements:
[java] init:
[java] generateScript:
[java] [eclipse.buildScript] Some inter-plug-in dependencies have not been satisfied.
[java] [eclipse.buildScript] Bundle org.jbpm.gd.jpdl.core:
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.xml.core_0.0.0.
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.sse.core_0.0.0.
[java] [eclipse.buildScript] Bundle org.jbpm.gd.jpdl.ui:
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.draw2d_0.0.0.
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.gef_0.0.0.
[java] BUILD FAILED
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.sse.core_0.0.0.
[java] D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\mainTargets.xml:23: The following error occurred while executing this l
ine:
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.xml.core_0.0.0.
[java] D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\mainTargets.xml:63: The following error occurred while executing this l
ine:
[java] D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\customTargets.xml:8: The following error occurred while executing this
line:
[java] D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\genericTargets.xml:63: Unable to find plug-in: org.jbpm.gd.jpdl.ui_0.0.
0. Please check the error log for more details.
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.xml.ui_0.0.0.
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.sse.ui_0.0.0.
[java] Total time: 1 second
[java] [eclipse.buildScript] Missing required plug-in org.eclipse.wst.common.ui_0.0.0.
[java] [eclipse.buildScript] Missing required plug-in org.jbpm.gd.jpdl.core_0.0.0.
[java] Java Result: 13
create.manifest:
[mkdir] Created dir: D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\target\manifest
move-feature:
BUILD FAILED
D:\work\java\jbpm.3\build\build.xml:59: The following error occurred while executing this line:
D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\build.xml:60: The following error occurred while executing this line:
D:\work\java\jbpm.3\designer\jpdl\org.jbpm.gd.jpdl.build\build.xml:191: Warning: Could not find file D:\work\java\jbpm.3\designer\jpdl\org.j
bpm.gd.jpdl.build\target\workspace\N.3.0.12-SNAPSHOT\org.jbpm.gd.jpdl.feature-3.0.12-SNAPSHOT.zip to copy.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979138#3979138
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979138
19 years, 8 months