...
- an example of declarative programming
- how to perform BPEL integration with ServiceMix
- how to use JmsTemplate for publishing and subscribing to ActiveMQ topics
...
This example has a client application, JMSClient, which sends a SOAP message to a ServiceMix binding component called myComponent. myComponent forwards the request to the PXE BPEL engine and waits for a response. In other words, JMSClient places a book order and myComponent receives the order and then sends it to the Webservice that takes orders. The client, JMSClient, and the binding component, myComponent, communicate via JMS; this communication is external to the ServiceMix JBI. myComponent and the PXE BPEL service engine communicate internally over the Normalized Message Router (NMR).
...
- Java Standard Edition 5.0
- Ant - http://ant.apache.org
- PXE - We support WS-BPEL via the PXE BPEL Engine from FiveSight.
Warning title Warning Note that NOTE: ServiceMix works on any Java SE 1.4 or later environment; however to use PXE you need to use a Java SE 5 or later platform is required. Before running this demoexample, use Java 1.5 to startup start up ServiceMix.
Running the BPEL Example
Before running this example, the following setup must be done. PXE has a JBI component and deployment unit, which can be auto-deployed in any JBI compliant container, in this case ServiceMix. To use PXE with ServiceMix, the PXE deployment unit must be placed in the install
directory so it will be auto-deployed in ServiceMix. NoteNOTE: The PXE deployment unit has already been put placed into the install
directory for you - take a look at the servicemix_install_dir\examples\bpel\install
directory to see the PXE jar file.
...
- From a command shell, go to the BPEL example directory:
whereCode Block cd [servicemix_install_dir]\examples\bpel
servicemix_install_dir
is the directory in which ServiceMix was installed. - Then type:
Code Block [servicemix_install_dir]\bin\servicemix servicemix.xml OR ..\..\bin\servicemix servicemix.xml
- To trigger the BPEL business process, send it some messages. To do this, compile and run a simple JMS client. The client is built and run from source code using Ant. Execute ant Ant from the BPEL directory:
servicemix_install_dir\examples\bpel
. To run the JMS client type:Code Block ant
Ant will compile and run the simple JMS client, JMSClient, which performs a JMS based request-response into the ServiceMix container before returning the results to the console.
...
The diagram below illustrates the logical flow of the program through the BPEL components.:
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
...
- The JMSClient, through ActiveMQConnectionFactory, connects to the topic named "demo.org.servicemix.source" and sends a text message containing the
message.soap
file. - myComponent, being a subscriber of the topic "demo.org.servicemix.source," receives the message.
- The myComponent implementation class, JmsServiceComponent, sends the message over the ServiceMix bus to the PxeBpelEngine by executing its onMessage() method. The destinationService property defines the destination of the message. Note NOTE: the destinationService property is found in the
servicemix.xml
file. - PxeBpelEngine sends a response back to myComponent through the ServiceMix bus, the NMR.
- myComponent uses the jmsTemplate bean to publish the message.
- jmsTemplate uses the jmsFactory bean to get a connection to the port associated with the JMS topic called "demo.org.servicemix.source." The message is published on the "demo.org.servicemix.source" topic.
- JMSClient, being a subscriber of topic "demo.org.servicemix.source," receives the message.
- The response is printed on the console.
...
The following table provides more details about the function of each component and bean in the servicemix.xml
file. :
Component or Bean ID | Description |
---|---|
jbi | jbi is the "id" of the JBI container and provides the basic infrastructure services for myComponent. During initialization, several singletons are instantiated: transactionManager, broker, jmsFactory, and jbi. Also, take note of the properties installationDirPath and deploymentDirPath defined in |
JMSClient | This Java standalone program, through the ActiveMQConnectionFactory, connects to topic "demo.org.servicemix.source." It then creates a text message from the file |
myComponent | This JMS service component subscribes to the "demo.org.servicemix.source" topic via its defaultDestinationName property specified in the |
jndi | This bean loads up database and transaction manager resources, which will be used by the other components in the system. More importantly, the JNDI context must be configured so that PXE can be deployed. |
Pxe-install.jar | This jarfile is located in the |
AsyncProcess-sa.jar | This jarfile is located in the |
broker | The broker bean uses the |
transactionManager | This bean is configured to be the default transaction manager for the jbi container. This transaction manager provides transactional services between the resource adapter (in this case the ActiveMQ resource adapter provided by the jencks JCA container) and components in the jbi container. |
jmsFactory | This bean listens on port 61616 and provides a pooled ActiveMQ connection. |
...