Access Keys:
Skip to content (Access Key - 0)

jBPM 4 Transport

This is an implementation of the BPM transport for use with JBoss jBPM 4.

It is based heavily upon the jBPM 3 transport that comes with Mule but has been updated for the new jBPM 4 api.  It currently ( as of 12/13/2009 ) works with jBPM 4.2.

Background

jBPM is a business process modeling tool and engine.  It allows you to graphically design your process workflow and can then execute that process.

An example might look something like this -

In combination with this transport, each step in the process can then be configured as a Mule endpoint.

For a better understanding of jBPM and its capabilities, please refer to the jBPM user guide.

Configuration

There are several parts to configuring the transport in Mule, the first of which is jBPM itself and the bpm mule connector.

<bpm:connector name="bpmConnector" bpms-ref="jbpm4" />

<spring:bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
   <spring:constructor-arg value="jbpm.cfg.xml" />
</spring:bean>

<spring:bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
<spring:bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<spring:bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
   jBPM provides a SpringConfiguration class which takes a jBPM config file as its constructor arg.  Additionally, you will need to set up the jBPM datasource and Hibernate session as described in the jBPM documentation.

Next we configure our Transport and inject some of the above objects

<spring:bean id="jbpm4" class="org.mule.transport.bpm.jbpm4.Jbpm4" destroy-method="destroy">
    <spring:property name="processEngine">
        <spring:ref local="processEngine"/>
    </spring:property>
</spring:bean>
And lastly, we configure any of the transport's custom jbpm activities that we intend to use.

<spring:bean id="sendMuleEventAndContinue"
    class="org.mule.transport.bpm.jbpm4.customactivity.SendMuleEventAndContinue"
    scope="prototype"
>
    <spring:property name="jbpm4" ref="jbpm4"/>
    <spring:property name="executionService" ref="executionService"/>
</spring:bean>

Using it in your process

Once you've configured the Spring beans as described above, you can begin using them in your process.

I've included the same components that were present in the jBPM 3 transport:

Custom Activities
  • SendMuleEvent - This activity sends a message to a Mule endpoint but does not advance the workflow process to the next step
  • SendMuleEventAndContinue - Same as above, however, it does advance the process
  • Continue - Simply advances the process

In your process definition, you would use them like this -

<custom expr="#{sendMuleEventAndContinue}" g="713,453,130,52" name="step1">

    <field name="endpoint"><string value="endpointName"/></field>
    <field name="payloadSource"><string value="variableName"/></field>

    <!-- variable defaults to "incoming" if not set -->
    <field name="variableName"><string value="variableNameToStoreResponseIn"/></field>
    <field name="synchronous"><true/></field>

    <transition g="-113,-8" name="to processResponse" to="processResponse"/>
</custom>
In this example -

  • the expr value refers to the name of the Spring bean you configured above.
  • endpoint is which Mule endpoint this request should be routed to
  • payloadSource is the jBPM process variable name of the object that you will be sending to Mule as the payload
  • variableName is the jBPM process variable name to store the return value in ( if not specified, it defaults to "incoming" )
  • synchronous is whether or not we will wait for a response from the Mule endpoint before proceeding
Event Listeners

These listener components may be attached to the start or end of process steps and perform some functionality. They cannot affect the workflow outcome.

  • LoggingEventListener - simply sends a message to the log.
  • StoreIncomingData - allows you to store data coming from Mule into a jBPM process variable
  • ValidateMessageSource - check if the request is coming from an expected Mule endpoint
  • ValidateMessageType - check if incoming data is of the expected Class

In your process definition you would attach the listener on a given process step -

 <state name="doSomething">
    <on event="start">
        <event-listener class="org.mule.transport.bpm.jbpm4.eventlistener.StoreIncomingData">
            <field name="variableName">
                <string value="incomingFile"/>
            </field>
        </event-listener>
    </on>

    <transition to="theNextStep"/>
</state>

Next Steps

Even though it was setup for the jBPM 3 transport, it would probably be beneficial to look at the example that ships with Mule - BPM Loanbroker, since the majority of the functionality is the same.

Adaptavist Theme Builder (3.3.3-conf210) Powered by Atlassian Confluence 2.10, the Enterprise Wiki.
Free theme builder license