In the
previous article in this series,
we talked about extending and expanding your enterprise integration to
account for an expanding architectural landscape that included diverse
backend systems.
In this article we want to provide an example project, called the
BRMS Fuse Integration Demo,
that demonstrates how to achieve some of the discussed use cases,
specifically how to integrate your service bus with a business process
engine.
Introduction
The main focus of this
article will be an actual integration project that provides you with an
architectural blueprint for calling out to your Red Hat JBoss Business
Rules Management System (BRMS) engine from your Red Hat JBoss Fuse
service bus messaging routes. The use cases that were discussed in the
previous article were as follows:
Use cases
- call JBoss Fuse (Camel) services from a business process (BPM)
- call JBoss BRMS to apply rules from JBoss Fuse (Camel) route, such as content based routing rules
- call a business process from a JBoss Fuse (Camel) route
The
project we provide covers the last use case, where we want to trigger a
business process from one of our JBoss Fuse (Camel) routes. Our project
provides the following aspects to provide you with a quick way to get
started and an architectural blueprint.
Example project
- Automated installation of JBoss Fuse
- Automated installation of JBoss BRMS
- Example BPM project deployed to JBoss BRMS
- Process is a three step process (Start → “Hello World” → End) that logs a message on execution
- Example (Camel) route deployed to JBoss Fuse
- Fuse (Camel) route that is triggered by messages from a specific data directory
- Logging of message from route
- SOAP Web service call from route to collect external information
- REST service call from a Bean from the camel route to start the external business process
JBoss BRMS and Fuse demo project
The reference project shows
an example of integrating JBoss BRMS with a focus on the BPM component
and JBoss Fuse. The environment consists of a JBoss Fuse instance with a
Fuse (Camel) deployment and a JBoss BRMS instance with a BPM project.
We touched on the business process, but let us examine the rest of the
projects in more detail. We have designed our architecture to loosely
couple the business process allowing access by other components, like
our JBoss Fuse example project, by using a REST client from our Camel
route. The REST client uses the Process ID and the proper user
credentials to start a new instance of the business process.
Peek under the hood
The
demo project will execute a lot of the mechanics out of our sight, so
let us take you on a tour of what is happening under the hood of our
project. If all goes according to plan it would step through our project
as follows:
- The src/data
directory defined in the Camel route is checked for xml messages which
contain a stock code in a SOAP message. In our example we are using RHT
as the symbol to get stock data on from the external SOAP Web Service.
Open up the message1.xml file to see the sample SOAP envelope and body.
- When a xml file is found then the body of the message is read in and displayed in the log message.
- Next the message is sent to the external SOAP web service to get the stock information.
- The response that is returned is then displayed in the log message.
- Next the startProcessFromCamel method in the RestClientSimple is called to start the business process that prints hello world. Additional information on calling the RestAPI that is provided by JBoss BRMS BPM component is found below. As noted in the section Future work, the stock data will be sent to to the business process.
- The process id is displayed in the log message.
The Fuse Component
The Fuse project starts with our simpleRoute project, which contains two parts. The first is our RestClientSimple
class, which allows us to define the business process ID and the user
credentials. We need this class in when dealing with starting our
process through the JBoss BRMS BPM RestAPI. The second is our camel-spring.xml file which contains our bean and route. A bean is defined with startit as the ID and RestClientSimple as the class.
Here is a closer look at a section of the camel-spring-xmlfile.
<bean id="startit" class="com.jboss.examples.RestClientSimple"/>
<route id="my_Sample_Camel_Route_with_CXF">
<from uri="file:src/data?noop=true"/>
<log message=">>> ${body}" loggingLevel="INFO"/>
<log message=">>> ${body}" loggingLevel="INFO"/>
<to uri="bean:startit?method=startProcessFromCamel"/>
<log message=">>> ${body}" loggingLevel="INFO"/>
</route>
</camelContext>
Note that the SOAP web service call to get stock data and then the call for the startProcessFromCamel method in the RestClientSimple
class. We aren't currently passing the stock data to the business
process, but that is possible, see the section on future work. Our RestSimpleClientgives three options for interaction with our JBoss BRMS BPM deployment.
- RestClientSimple starts a process without parameters
- RestClientStartWithParam starts a process with parameters
- RestClientTask starts a process and complete a task with form data
Future work
This
article has demonstrated how to integrate your service bus with a
business process engine. This example project solved only one of the use
cases and there are interesting extensions that could be added.
- The business process can be replaced by a more extensive example process, such as the Customer Evaluation Demo to show both BPM and rule integration.
- Parametrize the REST service such that diverse processes could be called.
- Pass the Stock data that was looked up in the Camel route as a parameter into the business process for display like the current Hello World.
- Deploy the SimpleRestClient service
in apart bundle within JBoss Fuse container. Currently it is a bean in
the route but it could be set as a proxy service that would receive a processID, user name, and user password.)
These
extensions we leave for you to work out, like homework exercises, as
you explore the integration scenarios that JBoss BRMS and JBoss Fuse can
solve for you.
(Co-authored by Kenny Peeples & Eric D. Schabell)