If you want to have concurrency (meaning the process will continue with other parts of the
flow while it is waiting for some other node to continue), you will need to model this
task you are waiting for as some external bit of work (using a work item node or a human
task node if you're waiting for a human user) and use asynchronous execution of your
work.
This means that the work item handler should not be executing synchronously (as that will
make the engine wait for it) but rather start execution (in a separate thread or by
invoking a service asynchronously) and return. Whenever the task is then completed, the
engine should be notified again (same as before, using manager.completeWorkItem(..)).
Internally, the engine will not use multi-threading as execution is (near) instantaneous.
Everything that cannot be executed immediately should be modeled using special nodes like
work item node, wait state, sub process node, etc.
Kris
----- Original Message -----
From: Pedro Maria Buitrago Mantilla
To: Rules Users List
Cc: rules-users-request(a)lists.jboss.org
Sent: Friday, April 09, 2010 9:59 PM
Subject: Re: [rules-users] RulesFlow - DroolsFlow - Parallelism - SplitNodes - Help
Thanks for you answer,
I thought the performance model took the two branches and processed in parallel in java.
Now, given that it is not, I would like to know that I can do in java to execute in
parallel my two subflows.
The launcher is:
package com.epmbog.esb.drools.mediator;
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.conf.MultithreadEvaluationOption;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import com.epmbog.drools.utils.Constantes;
import com.epmbog.esb.drools.workitems.EJBGenericWorkItemHandler;
public class TestProcess {
public static final void main(String[] args) {
try {
KnowledgeBase knowledgeBase = readRule();
StatefulKnowledgeSession ksession =
knowledgeBase.newStatefulKnowledgeSession();
ksession.getWorkItemManager().registerWorkItemHandler("TelnetConnection", new
EJBGenericWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler(
"TelnetDisonnection", new EJBGenericWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler(
"TelnetSendCommands", new EJBGenericWorkItemHandler());
HashMap<String, Object> paramMap = new HashMap<String,
Object>();
paramMap.put( Constantes.SOFT_SWITCH_IP , "10.134.2.2");
paramMap.put( Constantes.SOFT_SWITCH_USER , null);
paramMap.put( Constantes.SOFT_SWITCH_PASS , null);
paramMap.put( Constantes.SOFT_SWITCH_PORT , "6000");
paramMap.put( Constantes.UMG_IP , "10.134.2.11");
paramMap.put( Constantes.UMG_USER , "gestor");
paramMap.put( Constantes.UMG_PASS , "gestor");
paramMap.put( Constantes.UMG_PORT , "23");
Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> results = new HashMap<String, Object>();
Map<String, Object>
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados = new HashMap<String,
Object>();
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("softswitch_user",
"mediator");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("softswitch_pass",
"mediator");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("softswitch_number",
"6057000");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("softswitch_circuitInit",
"864");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("softswitch_circuitEnd",
"895");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("umg_port",
"00");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("umg_slot",
"03");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("umg_frame",
"1");
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados.put("umg_cardType",
"CUALQUIERJODA");
paramMap.put( Constantes.FM_PARAMETERS_MAP ,
mapaFormadoPorEsbSegunDatosInfraestructuraSolicitados);
parameters.put("factsMap", paramMap);
parameters.put("resultsMap", results);
ksession.startProcess( "com.epmbog.esb.drools.mediator.PriDigitalTest",
parameters );
ksession.fireAllRules();
System.out.println("Cualquier cosa");
} catch ( Throwable t ) {
t.printStackTrace();
}
}
private static KnowledgeBase readRule() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource(
"/com/epmbog/esb/drools/mediator/PriDigitalTest.rf", TestProcess.class ),
ResourceType.DRF );
kbuilder.add( ResourceFactory.newClassPathResource(
"/com/epmbog/esb/drools/mediator/SoftSwitchFlow.rf", TestProcess.class ),
ResourceType.DRF );
kbuilder.add( ResourceFactory.newClassPathResource(
"/com/epmbog/esb/drools/mediator/UMGFlow.rf", TestProcess.class ),
ResourceType.DRF );
KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
configuration.setOption( MultithreadEvaluationOption.YES );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
return kbase;
}
}
Thank you,
PEDRO MARIA BUITRAGO MANTILLA
Bogotá, Colombia
2010/4/9 Mauricio Salatino <salaboy(a)gmail.com>
When we define two parallel branches in a business process we represent a real
situation where two task needs to be completed in parallel. We are not expressing
something low level as Concurrent (multi threaded) programming.
Does this explanation answer your question?
2010/4/9 Pedro Maria Buitrago Mantilla <pmbtgun(a)gmail.com>
Greetings for all,
We're learning about jboss rules ( drools ), in particular, drools flow by the
workflow topic.
In the documentation, the parallelism is solved by means of split node of type 1
(AND).
However, when we execute the testing ,the execution is sequential.
In particular, the idea is that our workflow executes two subflows in parallel. For
this target we configured a
"split node" with type 'AND' and a "join node" with type
'AND', no more configuration, Is it required another configurations?
Is it problem of standalone applications? We don't know.
This is the case:
0. Drools:
Created-By: Apache Maven
Built-By: trikkola
Build-Jdk: 1.5.0_15
Specification-Title: Drools :: API
Specification-Version: 5.0.1
Specification-Vendor: JBoss Inc.
Implementation-Title: Drools :: API
Implementation-Version: 5.0.1
Implementation-Vendor-Id: org.drools
Implementation-Vendor: JBoss Inc.
1. ProcessXML:
<?xml version="1.0" encoding="UTF-8"?>
<process
xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="PriDigitalTest"
id="com.epmbog.esb.drools.mediator.PriDigitalTest"
package-name="com.epmbog.esb.drools.mediator" >
<header>
<variables>
<variable name="factsMap" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="java.util.HashMap" />
</variable>
<variable name="resultsMap" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="java.util.HashMap" />
</variable>
</variables>
</header>
<nodes>
<start id="1" name="Start" x="126"
y="16" width="48" height="48" />
<split id="19" name="AND" x="109"
y="95" width="80" height="40" type="1" />
<subProcess id="17" name="UMGSubFlow" x="16"
y="168" width="119" height="49"
processId="com.epmbog.esb.drools.mediator.UMGFlow"
waitForCompletion="false" independent="false" >
<mapping type="in" from="resultsMap"
to="resultsMap" />
<mapping type="in" from="factsMap"
to="factsMap" />
</subProcess>
<subProcess id="18" name="SoftSwitchSubFlow"
x="167" y="168" width="119" height="49"
processId="com.epmbog.esb.drools.mediator.SoftSwitchFlow"
waitForCompletion="false" independent="false" >
<mapping type="in" from="resultsMap"
to="resultsMap" />
<mapping type="in" from="factsMap"
to="factsMap" />
</subProcess>
<join id="20" name="Join(And)" x="110"
y="251" width="80" height="40" type="1" />
<end id="6" name="End" x="112"
y="414" width="80" height="40" />
</nodes>
<connections>
<connection from="1" to="19" />
<connection from="19" to="17" />
<connection from="19" to="18" />
<connection from="17" to="20" />
<connection from="18" to="20" />
<connection from="20" to="6" />
</connections>
</process>
2. Chart
We greatly appreciate your help, any suggestions? Thank you a lot
PEDRO MARIA BUITRAGO MANTILLA
Bogotá, Colombia
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
-
http://salaboy.wordpress.com
-
http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
------------------------------------------------------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm