Over a million developers have joined DZone.

From BPEL to the ESB and Back - Introduction to the Riftsaw-JBoss ESB Integration

DZone's Guide to

From BPEL to the ESB and Back - Introduction to the Riftsaw-JBoss ESB Integration

· Web Dev Zone
Free Resource

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.

One of the great strengths of the JBoss software is in the integrations between projects. In this post, we'll examine the Riftsaw - JBoss ESB integration to connect Riftsaw BPEL processes to ESB services.

Background - JBosssESB

Service Oriented Architecture (SOA) is not a single program or technology. It’s really a matter of software architecture or design. In hardware terms, a “bus” is a physical connector that ties together multiple systems or subsystems. Instead of having a large number of point-to-point connectors between pairs of systems, you connect each system to the bus once. An Enterprise Service Bus (ESB) does the same thing, logically, in software.

Instead of passing electric current or data over the bus to and from the connections (or “endpoints”) on the ESB, the ESB logically sits in the architectural layer above a messaging system. The messaging system allows for asynchronous communications between services over the ESB. In fact, when you are working with an ESB, everything is either a service (which in this context is your application software) or a message being sent between services. It’s important to note that a “service” is not automatically a web service. Other types of applications, using transports such as FTP or JMS, can also be services. Is an ESB the same thing as SOA (Service Oriented Architecture)? Not exactly. An ESB does not provide a Service Oriented Architecture, but it does provide the tools than can be used to build one–especially loose-coupling and asynchronous message passing. SOA is a series of principles, patterns, and best practices.

JBossESB[1] is an open source ESB implementation that supports multiple transports, protocols, a listener-action model for loose coupling of services, content based routing with JBoss Rules (Drools), and BPEL process management with Riftsaw.

The Riftsaw-JBoss ESB Integration

In reviewing the Riftsaw-JBossESB integration, the three topics to consider are:

  • Orchestrating ESB Services From BPEL in Riftsaw to the ESB
  • Making Calls From the ESB to the BPEL process definition in Riftsaw
  • Exception Handling

(As a point of reference, the Riftsaw-JBossESB integration is similar to the jBPM-JBossESB integration[2] in that it covers topics related to these three topics, but there is an important differences. In the Riftsaw-JBossESB integration, communication is synchronous (remember that we are working with web services) and follows the request-response pattern. As a result, the Riftsaw-JBossESB integration is simpler than the corresponding jBPM-JBossESB integration.)

We'll take these topics one at a time. Let's start with: Orchestrating ESB Services From BPEL in Riftsaw to the ESB.

You might think that a feature as powerful as the orchestration of ESB services would be difficult to configure, but actually, it's very straightforward. Remember that from the JBoss ESB's perspective, the BPEL process is a web service. The ESB can receive messages from a Riftsaw BPEL process just as it would from any web service. Let's illustrate this by modifying the Riftsaw BPEL "hello_world" quickstart to orchestrate a service as defined by the JBoss ESB "helloworld" quickstart.

Modifying the Quickstarts

In the BPEL "hello_world" quickstart process definition, we have to modify this file:

File: samples/quickstart/hello_world/bpel/HelloWorld.wsdl

   1    <?xml version="1.0" encoding="utf-8" ?>
2 <!--
3 ~ Licensed to the Apache Software Foundation (ASF) under one
4 ~ or more contributor license agreements. See the NOTICE file
5 ~ distributed with this work for additional information
6 ~ regarding copyright ownership. The ASF licenses this file
7 ~ to you under the Apache License, Version 2.0 (the
8 ~ "License"); you may not use this file except in compliance
9 ~ with the License. You may obtain a copy of the License at
10 ~
11 ~ http://www.apache.org/licenses/LICENSE-2.0
12 ~
13 ~ Unless required by applicable law or agreed to in writing,
14 ~ software distributed under the License is distributed on an
16 ~ KIND, either express or implied. See the License for the
17 ~ specific language governing permissions and limitations
18 ~ under the License.
19 -->
20 <wsdl:definitions
21 targetNamespace="http://www.jboss.org/bpel/examples/wsdl"
22 xmlns="http://schemas.xmlsoap.org/wsdl/"
23 xmlns:tns="http://www.jboss.org/bpel/examples/wsdl"
24 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
25 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
26 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
27 xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
29 <wsdl:message name="HelloMessage">
30 <wsdl:part name="TestPart" type="xsd:string"/>
31 </wsdl:message>
33 <wsdl:portType name="HelloPortType">
34 <wsdl:operation name="hello">
35 <wsdl:input message="tns:HelloMessage" name="TestIn"/>
36 <wsdl:output message="tns:HelloMessage" name="TestOut"/>
37 </wsdl:operation>
38 </wsdl:portType>
40 <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
41 <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
42 <wsdl:operation name="hello">
43 <soap:operation soapAction="" style="rpc"/>
44 <wsdl:input>
45 <soap:body
46 namespace="http://www.jboss.org/bpel/examples/wsdl"
47 use="literal"/>
48 </wsdl:input>
49 <wsdl:output>
50 <soap:body
51 namespace="http://www.jboss.org/bpel/examples/wsdl"
52 use="literal"/>
53 </wsdl:output>
54 </wsdl:operation>
55 </wsdl:binding>
56 <wsdl:service name="HelloService">
57 <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
58 <soap:address location="http://localhost:8081/bpel/processes/helloWorld"/>
59 </wsdl:port>
60 </wsdl:service>
62 <plnk:partnerLinkType name="HelloPartnerLinkType">
63 <plnk:role name="me" portType="tns:HelloPortType"/>
64 <plnk:role name="you" portType="tns:HelloPortType"/>
65 </plnk:partnerLinkType>
66 </wsdl:definitions>

 The change to note is on line 58: Since we want the ESB application to define a listener to "listen" for incoming http traffic, we have to change the port for the BPEL process to not conflict with the JBoss AS server itself. We've selected port 8081 as the new port for the BPEL process. Remember, that as far as the ESB is concerned, the BPEL process is a web service.

In the JBoss ESB "helloworld" quickstart, we have to modify these 4 files:

File: jbossesb-4.6/samples/quickstarts/helloworld/jboss-esb.xml

 1    <?xml version = "1.0" encoding = "UTF-8"?>
2 <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
4 <providers>
5 <jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
6 <jms-bus busid="quickstartGwChannel">
7 <jms-message-filter
8 dest-type="QUEUE"
9 dest-name="queue/quickstart_helloworld_Request_gw"
10 />
11 </jms-bus>
12 <jms-bus busid="quickstartEsbChannel">
13 <jms-message-filter
14 dest-type="QUEUE"
15 dest-name="queue/quickstart_helloworld_Request_esb"
16 />
17 </jms-bus>
19 <jms-bus busid="quickstartEsbReplyChannel">
20 <jms-message-filter
21 dest-type="QUEUE"
22 dest-name="queue/quickstart_helloworld_Request_esb_reply"
23 />
24 </jms-bus>
27 </jms-provider>
29 <jbr-provider name="JBR-Http-1" protocol="http" host="localhost">
30 <jbr-bus busid="Http-1" port="8081"/>
31 </jbr-provider>
32 </providers>
34 <services>
35 <service
36 category="FirstServiceESB"
37 name="SimpleListener"
38 description="Hello World">
40 <listeners>
41 <jms-listener name="JMS-Gateway"
42 busidref="quickstartGwChannel"
43 is-gateway="true"
44 />
45 <jms-listener name="helloWorld"
46 busidref="quickstartEsbChannel"
47 />
48 <jbr-listener name="Http-Gateway" busidref="Http-1" is-gateway="true"/>
50 </listeners>
52 <actions mep="RequestResponse">
53 <action name="action1"
54 class="org.jboss.soa.esb.samples.quickstart.helloworld.MyJMSListenerAction"
55 process="displayMessage"
56 />
57 <action name="action2" class="org.jboss.soa.esb.actions.SystemPrintln">
58 <property name="printfull" value="false"/>
59 </action>
60 <!-- The next action is for Continuous Integration testing -->
61 <action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore"/>
62 </actions>
63 </service>
64 </services>
66 </jbossesb>
The changes are:
  • Lines 29-31, and 48: Here's where we define the HTTP gateway listener that will watch for the message (request) sent by the BPEL process.
  • Line 52: This is an important change. In the original ESB helloworld quickstart, the message exchange pattern (mep) was set to "OneWay." In our modified quickstart, we need to have a response sent back to the BPEL process to complete the request/response sequence.
  • Lines 19-23: What's this all about? For each ESB-unaware gateway channel, the ESB requires a corresponding ESB-aware channel. In this context, "ESB-aware" refers to a channel communicating via messages in the org.jboss.soa.esb.message.Message format, and "ESB-unaware" refers to communicating via messages in a format other than (org.jboss.soa.esb.message.Message). We also have to add this ESB-aware channel to these files:

File: jbossesb-4.6/samples/quickstarts/helloworld/deployment.xml

   1    <jbossesb-deployment>
2 <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_esb_reply</depends>
3 <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_esb</depends>
4 <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_gw</depends>
5 </jbossesb-deployment>

File: jbossesb-4.6/samples/quickstarts/helloworld/jbm-queue-service.xml

   1    <?xml version="1.0" encoding="UTF-8"?>
2 <server>
4 <mbean code="org.jboss.jms.server.destination.QueueService"
5 name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_esb_reply"
6 xmbean-dd="xmdesc/Queue-xmbean.xml">
7 <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
8 <depends>jboss.messaging:service=PostOffice</depends>
9 </mbean>
11 <mbean code="org.jboss.jms.server.destination.QueueService"
12 name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_esb"
13 xmbean-dd="xmdesc/Queue-xmbean.xml">
14 <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
15 <depends>jboss.messaging:service=PostOffice</depends>
16 </mbean>
17 <mbean code="org.jboss.jms.server.destination.QueueService"
18 name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_gw"
19 xmbean-dd="xmdesc/Queue-xmbean.xml">
20 <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
21 <depends>jboss.messaging:service=PostOffice</depends>
22 </mbean>
23 </server>

Finally, we have to modify build.xml to reference the changed port number for the web services - only one line is changed:

    33   <arg value="http://localhost:8081/bpel/processes/helloWorld"/>

After we deploy both the quickstarts, we can initiate the ESB service orchestration by executing the "ant sendhello" command for the Riftsaw BPEL hello_world process. The server log shows this output:

22:38:51,690 INFO  [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
22:38:51,700 INFO [STDOUT] Body: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.jboss.org/bpel/examples/wsdl">
22:38:51,701 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
22:38:51,716 INFO [STDOUT] Message structure:
22:38:51,716 INFO [STDOUT] [<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.jboss.org/bpel/examples/wsdl">

And the Riftsaw BPEL hello_world process client shows this output:

$ ant sendhello
Buildfile: build.xml

[echo] Send test message to: Quickstart_bpel_hello_world
[java] <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.jboss.org/bpel/examples/wsdl">
[java] <soapenv:Header/>
[java] <soapenv:Body>
[java] <wsdl:hello>
[java] <TestPart>Hello</TestPart>
[java] <TestPart2>Hello</TestPart2>
[java] </wsdl:hello>
[java] </soapenv:Body>
[java] </soapenv:Envelope>

Total time: 2 seconds


Closing Thoughts

The fact that from the ESB's perspective, a Riftsaw BPEL process is a web service, makes orchestrating ESB processes a straightforward task. In the next post to this blog, we look going back the other way and making calls from the JBossESB to a BPEL process definition in Riftsaw.


As always, I want to thank the Riftsaw community (especially Kurt Stam and Gary Brown), both for creating Riftsaw (and its documentation and examples) and for their timely review input for this blog post.

Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.


Published at DZone with permission of Len DiMaggio, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}