WebSphere MQ, when used as a JMS provider, can be leveraged to implement one of the widely used architecture patterns, the Pub-Sub model. In this use case, we have a message flow as the service provider that connects to WMQ publisher and another consumer message flow that uses WMQ topics as a subscriber within WebSphere Message Broker. Here message selectors are used as filter criteria for a given topic string. The steps below will guide you through the implementation of the use case.
Create Topic to Publish Messages
1. Create Topic to publish messages: Expand QM (MQ Explorer) -> Select “Topics” -> New -> Topic
Create JMS Administered Objects
1. Create initial context under “JMS Administered Objects” ->”Add Initial Context.”
2. Under Initial context created above, create Connection Factory and specify the Base Queue Manager.
Within the install location, run “JMSAdmin.bat”. In Windows environment you would most likely find it in location below:
C:\Program Files (x86)\IBM\WebSphere MQ\java\bin |
In Unix server, you would have to run using the command below.
[mqm@localhost bin]$ ./JMSAdmin -cfg /tmp/JMSAdmin.config |
3. Create Destination (Queue/Topic) under Initial Context created in Step 2 and with the same Topic string as we created in Step 1 highlighted below.
Message Flow Configuration
1. Create Publish flow and configure JMSOutput node to specify the Topic.
2. Optionally, you could specify the Application Property to be used as Message Selector either using ESQL(a) or JMSHeader node(b).
a)
SET OutputRoot.JMSTransport.Transport_Folders.Application_Properties.SourceSystem = 'LAWSON'; |
b)
3. Create Subscription message flow to read messages published on a topic using Message Selectors.
Creating Subscriptions Using MQ Explorer
You could also create multiple subscriptions for the same Topic but with different destination queue and message selector: Expand QM (MQ Explorer) -> Select “Subscriptions” -> New -> subscription.
Note: Select previously created Topic, destination Queue name, and message selector when creating the subscription.
How To: Message Selectors in WMB & WMQ as JMS Publish Subscriber was first posted on November 24, 2015 at 7:10 am.