Choose JBoss jBPM Process Definition from the Selection wizard.
Save the process definition. Use a separate directory for each process definition to avoid confusion.
Start to "drag-and-drop" items from the jBPM Integrated Development Environment 's menu palette into the Process Design view. You can switch between the design and source modes to check XML elements as you add them.
Add the XML fragments that are needed for the integration.
Before building the order process diagram, create and test the three services. These are ordinary ESB services and they are defined in the jboss-esb.xml file. An example configuration with service names and categories is shown below:
<services>
<service category="BPM_orchestration4_Starter_Service"
name="Starter_Service"
description="BPM Orchestration Sample 4: Use this service to start a
process instance">
<!-- .... -->
</service>
<service category="BPM_Orchestration4" name="IntakeService"
description="IntakeService: transforms, massages, calculates priority">
<!-- .... -->
</service>
<service category="BPM_Orchestration4" name="DiscountService"
description="DiscountService">
</service>
<service category="BPM_Orchestration4" name="ShippingService"
description="ShippingService">
<!-- .... -->
</service>
</services>
<services>
<service category="BPM_orchestration4_Starter_Service"
name="Starter_Service"
description="BPM Orchestration Sample 4: Use this service to start a
process instance">
<!-- .... -->
</service>
<service category="BPM_Orchestration4" name="IntakeService"
description="IntakeService: transforms, massages, calculates priority">
<!-- .... -->
</service>
<service category="BPM_Orchestration4" name="DiscountService"
description="DiscountService">
</service>
<service category="BPM_Orchestration4" name="ShippingService"
description="ShippingService">
<!-- .... -->
</service>
</services>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Refer to these services by using either the EsbActionHandler or EsbNotifier action handler. (Choose the EsbActionHandler in cases where the JBoss Business Process Manager expects a response, and the EsbNotifier when none is required.)
Now that the ESB services are known, drag the Start state node into the design view. A new process instance will begin at this node.
Drag in a node and name it Intake Order.
Connect the Start and the Intake Order nodes by selecting Transition from the menu and then clicking on each of them. An arrow connecting them will appear. It will be pointing towards the first Intake Order.
Add the Service and Category names to the Intake Node. Select the Source view. You will be able to see the source code for the Intake Order node. It should look like this:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Add the EsbActionHandler class reference, followed by the sub-element configuration settings for the service category and name, BPM_Orchestration4 and the IntakeService. It should look like this:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Send some JBoss Business Process Manager context variables along with the service call using the following code. (In the example below, there is a variable named entireOrderAsXML which is to be set in the default position in the message body.)
Copy to ClipboardCopied!Toggle word wrapToggle overflow
This will cause the XML-based contents of the entireOrderAsXML variable to end up in the body of the message. Now the IntakeService can access the message and process it by letting it flow through each action in the pipeline. When the last action is reached, the replyTo property is checked and the message is sent to the JBpmCallBack service.
This makes a call back into the JBoss Business Process Manager, signaling the transition from the Intake Order node to the next one (in this case, Review Order).
Next, send some variables from the message to the node. Note that entire objects can be sent, as long both contexts can load the object's class. To retain the ability to "map back" to the JBoss Business Process Manager, add an esbToEsbVars element:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
When this service returns, the following variables are then stored in the JBoss Business Process Manager's context:
entireOrderAsXML
entireOrderAsObject
entireCustomerAsObject
In addition, for demonstration purposes, there are also some flattened variables:
order_orderid
order_totalAmount
order_priority
customer_firstName
customer_lastName
customer_status
You must now review the order process manually. Add a task node with the task called Order Review. These jobs need to be performed by someone with the actor_iduser.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
In this case, the same form is applied to two task nodes. There is a reference to the variables in the Review Order form as shown in the following sample code. (This, in turn, refers to the variables that are set in the JBoss Business Process Manager's context.)
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The service receives the customer, orderHeader and the entireOrderAsXML data. It then computes a discount. The response maps the body.order_orderDiscount value onto a JBoss Business Process Manager context variable called order_-discount. The process is signaled, which tells it to move to the Review Discount node.
Review the discount, which is set to a value of 8.5. Click on Save and Close. The process will move to the Ship It node, which is also an ESB service.
To circumvent the order process before the Ship It service completes, use the EsbNotifier action handler by attaching it to the outgoing transition as shown below:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
After notifying the ShippingService, the order process moves to the end state and terminates. (The ShippingService itself may still be finishing.)
In the bpm_orchestration4 quick start, the JBoss Rules engine is used to determine whether this order is to be shipped via the normal or the express method.