[rules-users] RulesFlow - DroolsFlow - Parallelism - Split Nodes - Help

Pedro Maria Buitrago Mantilla pmbtgun at gmail.com
Fri Apr 9 15:59:03 EDT 2010


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 at 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 at 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/processdrools-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*
>> *
>> *
>> [image: PriDigitalTest.JPG]
>>
>> We greatly appreciate your help, any suggestions? Thank you a lot
>>
>>
>> PEDRO MARIA BUITRAGO MANTILLA
>> Bogotá, Colombia
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100409/a22bc528/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 17132 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20100409/a22bc528/attachment.jpe 


More information about the rules-users mailing list