Oracle Middleware and IBM MQ Series - Use case: MQ Adapter main

Oracle Middleware and IBM MQ Series – Use case: MQ Adapter

Series

This is the fourth post in a series on using Oracle Middleware with IBM MQ Series. In this series, the following articles are available:

  1. IBM MQ Series Installation and Configuration
  2. Configuration of JMS and MQ Adapters in WebLogic
  3. Use case: JMS Adapter and MQ
  4. Use case: MQ Adapter
  5. Use case: MQ Transport

MQ Adapter and MQ

This blog covers the exchange of text messages over MQ, using the MQ Adapter in both BPEL and Service Bus.

 

1. Overview

This blog covers the MQ Adapter use case. It is structured in the following way:

  1. Overview
  2. Use case description
  3. Prepare the file system
  4. Service Bus produces msg with MQ Adapter
  5. BPEL consumes msg with MQ Adapter
  6. BPEL produces msg with MQ Adapter
  7. Service Bus consumes msg with MQ Adapter
  8. Testing the use case

The projects can also be downloaded here.
 

2. Use case description

The use case covers the usage of the MQ adapter by both SB and BPEL, for both receiving and sending messages. The following 2 situations are covered:

1. SB puts a msg on an MQ queue, BPEL consumes a msg from the MQ queue

  • a file is put in directory …/usecase/mqadapter/osb/in
  • the SB service picks up the file with the file adapter
  • the SB service puts the file on queue TEXT_MSG_REQUEST_Q with the MQ adapter
  • the BPEL process picks up the msg from queue TEXT_MSG_REQUEST_Q with the MQ adapter
  • the BPEL process puts the message in directory …/usecase/mqadapter/bpel/out

 

mq_request

 

2. BPEL puts a msg on an MQ queue, SB consumes a msg from the MQ queue

  • a file is put in directory …/usecase/mqadapter/bpel/in
  • the BPEL process picks up the file with the file adapter
  • the BPEL process puts the file on queue TEXT_MSG_REPLY_Q with the MQ adapter
  • the SB service picks up the msg from queue TEXT_MSG_REPLY_Q with the MQ adapter
  • the SB service puts the message in directory …/usecase/mqadapter/osb/out

 

mq_reply

 

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

[developer@localhost ~]$ pwd
/home/developer
[developer@localhost ~]$ mkdir usecase
[developer@localhost ~]$ mkdir usecase/mqadapter
[developer@localhost ~]$ mkdir usecase/mqadapter/osb
[developer@localhost ~]$ mkdir usecase/mqadapter/osb/in
[developer@localhost ~]$ mkdir usecase/mqadapter/osb/out
[developer@localhost ~]$ mkdir usecase/mqadapter/bpel
[developer@localhost ~]$ mkdir usecase/mqadapter/bpel/in
[developer@localhost ~]$ mkdir usecase/mqadapter/bpel/out

4. Service Bus produces msg with MQ Adapter

Starting point is a service bus project with a File Adapter that picks up a message from the directory /home/developer/usecase/mqadapter/osb/in.

 

mq_401_FileToMq_SB-FileAdapter

 

Now, insert an MQ Adapter

mq_402_FileToMq_SB-insert-mq-adapter

 

Give MQ Adapter the name ‘MqOut’

mq_403_FileToMq_SB-mq-adapter-01

 

For the MQ Connection JNDI Name, browse on your server to find ‘eis/MQ/AMIS’

mq_404_FileToMq_SB-mq-adapter-02

 

In the Adapter Interface, check button ‘Define from operation and schema (specified later)’

mq_405_FileToMq_SB-mq-adapter-03

 

Select the operation ‘Put Message into MQ’, which sets the Operation Type to ‘Enqueue Message’

mq_406_FileToMq_SB-mq-adapter-04

 

In the ‘Put Message into MQ’ page, enter the Destination Name ‘TEXT_MSG_REQUEST_Q’

mq_407_FileToMq_SB-mq-adapter-05

 

On the Advanced Options page, just click Next

mq_308_FileToJms_SB-jms-adapter-06

 

For the Message Schema, select ‘Native format translation is not required (Schema is Opaque)’

mq_409_FileToMq_SB-mq-adapter-07

 

Click on Finish in the last wizard screen.

The Service Bus screen now shows the adapter:

mq_410_FileToMq_SB-mq-adapter-completed

 

Now, connect the Pipeline ‘FileToMq’ to the MQ Adapter ‘MqOut’:

mq_411_FileToMq_SB-mq-adapter-connected

 

To get it to work, there is still one thing to do in the FileToMq pipeline. By default, in the Routing the Operation is set to ‘Use inbound operation for outbound’. That needs to be changed to ‘Enqueue’, i.e. the operation of the MQ Adapter.

mq_412_FileToMq_SB-mq-adapter-set-operation

 

Now, the project can be deployed.

 

5. BPEL consumes msg with MQ Adapter

Starting point is an empty BPEL process with a File Adapter that writes a file to the directory /home/developer/usecase/mqadapter/bpel/out:

mq_450_MqToFile_BPEL_composite

 

and

mq_451_MqToFile_BPEL_bpel

 

Now the MQ Adapter will be added:

mq_452_MqToFile_BPEL_insert-mq-adapter

 

Give MQ Adapter the name ‘MqIn’

mq_453_MqToFile_BPEL_mq-adapter-01

 

For the MQ Connection JNDI Name, browse on your server to find ‘eis/MQ/AMIS’

mq_454_MqToFile_BPEL_mq-adapter-02

 

In the Adapter Interface, check button ‘Define from operation and schema (specified later)’

mq_455_MqToFile_BPEL_mq-adapter-03

 

Set the Operation Type to ‘Get Message from MQ’ and watch the Operation Name being set to ‘Dequeue’

 

mq_456_MqToFile_BPEL_mq-adapter-04

 

In the ‘Get Message from MQ’ page, enter the Queue Name ‘TEXT_MSG_REQUEST_Q’

mq_457_MqToFile_BPEL_mq-adapter-05

 

For the Message Schema, select ‘Native format translation is not required (Schema is Opaque)’

mq_457_MqToFile_BPEL_mq-adapter-06

 

Click on Finish in the last wizard screen:

mq_458_MqToFile_BPEL_mq-adapter-06

 

The composite screen now shows the MQ Adapter:

mq_459_MqToFile_BPEL_composite

 

Now, the MQ Adapter must be connected to the BPEL process. Set Delivery ot ‘Sync’ and set Transaction to ‘notSupported’:

mq_460_MqToFile_BPEL_composite-connecting

 

Complete the BPEL process in the following steps:
– add a Receive from MqIn 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

mq_461_MqToFile_BPEL_BPEL

 

The project can now be deployed to the SOA Server.

 

6. BPEL produces msg with MQ Adapter

 

Here, a BPEL process reads a file with the File Adapter from directory /home/developer/usecase/mqadapter/bpel/in. Then, it uses the MQ Adapter to put the read file on the queue TEXT_MSG_REPLY_Q. Shown in the figure below:

mq_462_FileToMq_BPEL_composite

 

The File Adapter configuration is not described.

The MQ Adapter configuration is quite similar to the description in the section ‘BPEL consumes msg with MQ 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: MqOut (different from previous section)
  • MQ Connection JNDI Name: eis/MQ/AMIS (same as previous section)
  • Adapter Interface: ‘Define from operation and schema (specified later)’ (same as previous section)
  • Operation Type: ‘Put Message into MQ’ (different from previous section)
  • Produce Operation Parameters / Destination Name: TEXT_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:

mq_462_FileToMq_BPEL_composite

 

The BPEL process looks like:

mq_463_FileToMq_BPEL_BPEL

 

7. Service Bus consumes msg with MQ Adapter

Here, on SB service reads a message from MQ queue TEXT_MSG_REPLY_Q with the MQ Adapter. Then, it uses the File Adapter to write that message to directory /home/developer/usecase/mqadapter/osb/out. Shown in the figure below:

mq_471_MqToFile_SB_SB-connected

 

The File Adapter configuration is not described.

The MQ Adapter configuration is quite similar to how it was done in the previous SB service. The list below shows what as to be entered on the Wizard pages and where it is (not) different from the earlier given usage of MQ Adapter

  • Service name: MqIn (different from previous section)
  • MQ Connection JNDI Name: eis/MQ/AMIS (same as previous section)
  • Adapter Interface: ‘Define from operation and schema (specified later)’ (same as previous section)
  • Operation Type: ‘Get Message from MQ’ (different from previous section)
  • Get Message from MQ: Queue Name is TEXT_MSG_REPLY_Q (different from previous section)
  • Message Schema: ‘Native format translation is not required (Schema is Opaque)’ (same as previous section)

The Service Bus screen now shows the adapter:

mq_470_MqToFile_SB_SB

 

Now, connect the Pipeline ‘FileToMq’ to the File Adapter ‘FileIn’:

mq_471_MqToFile_SB_SB-connected

 

To get it to work, there is still one thing to do in the FileToMq pipeline. By default, in the Routing the Operation is set to ‘Use inbound operation for outbound’. That needs to be changed to ‘Write’, i.e. the operation of the File Adapter.

mq_472_MqToFile_SB_pipeline

 

 

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/mqadapter/osb/in
  • ~/usecase/mqadapter/bpel/in

… and then wait for them to appear in resp:

  • ~/usecase/mqadapter/bpel/out
  • ~/usecase/mqadapter/osb/out

Mind the default 1 min polling the of the File Adapter.

One Response

  1. senthil August 1, 2019