Series
This is the third post in a series on using Oracle Middleware with IBM MQ Series. In this series, the following articles are available:
- IBM MQ Series Installation and Configuration
- Configuration of JMS and MQ Adapters in WebLogic
- Use case: JMS Adapter and MQ
- Use case: MQ Adapter
- Use case: MQ Transport
JMS Adapter and MQ
This blog covers the exchange of JMS messages over MQ, using the JMS adapter in both BPEL and Service Bus.
1. Overview
This blog is structured in the following way:
1. use case description
2. prepare the file system
3. Service Bus produces msg with JMS Adapter
4. BPEL consumes msg with JMS Adapter
5. BPEL produces msg with JMS Adapter
6. Service Bus consumes msg with JMS Adapter
7. Testing the use case
The projects can be downloaded here.
2. Use case description
The use case covers the usage of the JMS adapter by both SB and BPEL, for both receiving and sending messages. The following 2 situations are covered:
1. SB puts a msg on a JMS queue, BPEL consumes a msg from the JMS queue
- a file is put in directory …/usecase/jmsadapter/osb/in
- the SB service picks up the file with the file adapter
- the SB service puts the file on queue JMS_MSG_REQUEST_Q with the JMS adapter
- the BPEL process picks up the msg from queue JMS_MSG_REQUEST_Q with the JMS adapter
- the BPEL process puts the message in directory …/usecase/jmsadapter/bpel/out
2. BPEL puts a msg on a JMS queue, SB consumes a msg from the JMS queue
- a file is put in directory …/usecase/jmsadapter/bpel/in
- the BPEL process picks up the file with the file adapter
- the BPEL process puts the file on queue JMS_MSG_REPLY_Q with the JMS adapter
- the SB service picks up the msg from queue JMS_MSG_REPLY_Q with the JMS adapter
- the SB service puts the message in directory …/usecase/jmsadapter/osb/out
In order to complete this use case, the File Adapter is used. The File Adapter is used in 4 different situations, but not described as that is not the focus of this article.
If you want to know more about the complete projects that are used, you can download the sources here.
3. Prepare the file system
Some test directories for the File Adapter need to be created:
[developer@localhost ~]$ pwd<br>/home/developer<br>[developer@localhost ~]$ mkdir usecase<br>[developer@localhost ~]$ mkdir usecase/jmsadapter<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/osb<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/osb/in<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/osb/out<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/bpel<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/bpel/in<br>[developer@localhost ~]$ mkdir usecase/jmsadapter/bpel/out
4. Service Bus produces msg with JMS Adapter
Starting point is a service bus project with a File Adapter that picks up a message from the directory /home/developer/usecase/jmsadapter/osb/in.
Now, insert an JMS Adapter
Give JMS Adapter the name ‘JmsOut’
Select JMS Provider ‘Third Party’
For the JMS Connection JNDI Name, browse on your server to find ‘eis/jms/AMIS’
In the Adapter Interface, check button ‘Define from operation and schema (specified later)’
Set the Operation Type to ‘Produce Message’
In the ‘Produce Operation Parameters’ page, enter the Destination Name ‘JMS_MSG_REQUEST_Q’
For the Message Schema, select ‘Native format translation is not required (Schema is Opaque)’
Click on Finish in the last wizard screen:
The Service Bus screen now shows the adapter:
Now, connect the Pipeline ‘FileToJms’ to the JMS Adapter ‘JmsOut’:
To get it to work, there is still one thing to do in the FileToJms pipeline. By default, in the Routing the Operation is set to ‘Use inbound operation for outbound’. That needs to be changed to ‘Produce_Message’, i.e. the operation of the JMS Adapter.
Now, the project can be deployed.
5. BPEL consumes msg with JMS Adapter
Starting point is an empty BPEL process with a File Adapter that writes a file to the directory /home/developer/usecase/jmsadapter/bpel/out:
and
Now the JMS Adapter will be added:
Give JMS Adapter the name ‘JmsIn’
Select JMS Provider ‘Third Party’
For the JMS Connection JNDI Name, browse on your server to find ‘eis/jms/AMIS’
In the Adapter Interface, check button ‘Define from operation and schema (specified later)’
Set the Operation Type to ‘Consume Message’
In the ‘Consume Operation Parameters’ page, enter the Destination Name ‘JMS_MSG_REQUEST_Q’
For the Message Schema, select ‘Native format translation is not required (Schema is Opaque)’
Click on Finish in the last wizard screen:
The composite screen now shows the JMS Adapter:
Now, the JMS Adapter must be connected to the BPEL process. Set Delivery ot ‘Sync’ and set Transaction to ‘notSupported’:
Complete the BPEL process in the following steps:
- adding a Receive from JmsIn that initiates the process (‘Create Instance’)
- add an invoke of FileOut
- add an Assign that maps the opaque payload received from JmsIn to the opaque payload of the invoked FileOut
The project can now be deployed to the SOA Server.
6. BPEL produces msg with JMS Adapter
Here, a BPEL process reads a file with the File Adapter from directory /home/developer/usecase/jmsadapter/bpel/in. Then, it uses the JMS Adapter to put the read file on the queue JMS_MSG_REPLY_Q. Shown in the figure below:
The File Adapter configuration is not described.
The JMS Adapter configuration is quite similar to the description in the section ‘BPEL consumes msg with JMS Adapter’, The list below indicates what has to be entered on the Wizard pages and where it is (not) different from the earlier given usage of JMS Adapter
- Reference name: JmsOut (different from previous section)
- JMS Provider: ‘Third Party’ (same as previous section)
- JMS Connection JNDI Name: eis/jms/AMIS (same as previous section)
- Adapter Interface: ‘Define from operation and schema (specified later)’ (same as previous section)
- Operation Type: ‘Produce Message’ (different from previous section)
- Produce Operation Parameters / Destination Name: JMS_MSG_REPLY_Q (different from previous section)
- Message Schema: ‘Native format translation is not required (Schema is Opaque)’ (same as previous section)
The composite looks like:
The BPEL process looks like:
The project can now be deployed to the SOA Server.
7. Service Bus consumes msg with JMS Adapter
Here, a SB Service reads a message from MQ queue JMS_MSG_REPLY_Q with the JMS Adapter. Then, it uses the File Adapter and puts the message in directory /home/developer/usecase/jmsadapter/osb/out. Shown in the figure below:
The File Adapter configuration is not described.
The JMS Adapter configuration is quite similar to the description in the section ‘BPEL consumes msg with JMS Adapter’, The list below indicates what has to be entered on the Wizard pages:
- Reference name: JmsIn
- JMS Provider: ‘Third Party’
- JMS Connection JNDI Name: eis/jms/AMIS
- Adapter Interface: ‘Define from operation and schema (specified later)’
- Operation Type: ‘Produce Message’
- Produce Operation Parameters / Destination Name: JMS_MSG_REPLY_Q
- Message Schema: ‘Native format translation is not required (Schema is Opaque)’
The composite looks like:
The SB pipeline looks like:
Remember to set the right outbound operation in the pipeline.
Now, the project can be deployed.
8. Testing the use case
The projects can also be downloaded here.
The projects can be tested by copying some test message into the directories:
- ~/usecase/jmsadapter/osb/in
- ~/usecase/jmsadapter/bpel/in
… and then wait for them to appear in resp:
- ~/usecase/jmsadapter/bpel/out
- ~/usecase/jmsadapter/osb/out
Mind the default 1 min polling the of the File Adapter.
Such a nice way to present. Thank you.