transformatech using it to transform the way you do business tags

10
TransformaTech Using IT to transform the way you do business TAGS COBOL, IBM, MQ, MQInput, Pub, pub/sub, Publication, Publication Node, Publisher, RFHUTIL, Sub, Subscriber, Subscription, Topic, TransformaTech, WebSphere Message Broker, WMB, XML, XML TO COBOL Simple PUB/SUB Example Using WebSphere Message Broker v7 and MQ v 7 by achourelabbes on September 13, 2013 1. OVERVIEW PUB/SUB The Pub/Sub design pattern is based on a scenario where clients (publishers) “publish” messages to topics. Then one or more clients (subscribers) that are interested in that topic can “subscribe” to that topic. Publishers and Subscribers are loosely coupled and are not aware of each other. This is different than the point-to-point implementation where sender and receivers are tightly coupled at minimum from a connectivity standpoint. Following is a very high-level illustration of Pub/Sub: (http://transformatech.files.wordpress.com/2013/09/sub_pub.jpg) 2. OVERVIEW OF OUR WMB/MQ PUB/SUB SCENARIO There are many ways to implement a Pub/Sub design pattern depending on your platform. To illustrate a simple Pub/Sub example, this blog is going to focus on one simple technique using WMB v7 and MQ v7. There are also other ways to implement this depending on what version of WMB you are using. These other techniques will not be covered in this blog, but detailed information can be found in the MQ and WMB infocenters.

Upload: google

Post on 21-Feb-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

TransformaTechUsing IT to transform the way you do business

TAGSCOBOL, IBM, MQ, MQInput, Pub, pub/sub, Publication, Publication Node, Publisher, RFHUTIL,Sub, Subscriber, Subscription, Topic, TransformaTech, WebSphere Message Broker, WMB, XML,XML TO COBOL

Simple PUB/SUB Example Using WebSphereMessage Broker v7 and MQ v 7

by achourelabbes on September 13, 20131. OVERVIEW PUB/SUB

The Pub/Sub design pattern is based on a scenario where clients (publishers)“publish” messages to topics. Then one or more clients (subscribers) that areinterested in that topic can “subscribe” to that topic. Publishers and Subscribers

are loosely coupled and are not aware of each other. This is different than the point-to-pointimplementation where sender and receivers are tightly coupled at minimum from a connectivitystandpoint.

Following is a very high-level illustration of Pub/Sub:

(http://transformatech.files.wordpress.com/2013/09/sub_pub.jpg)

2. OVERVIEW OF OUR WMB/MQ PUB/SUB SCENARIO

There are many ways to implement a Pub/Sub design pattern depending on your platform. Toillustrate a simple Pub/Sub example, this blog is going to focus on one simple technique usingWMB v7 and MQ v7. There are also other ways to implement this depending on what version ofWMB you are using. These other techniques will not be covered in this blog, but detailedinformation can be found in the MQ and WMB infocenters.

Our Simple Example is going to leverage a WMB message flow with an MQ Input Node to definewhat topic to put to and WMB Publication Node to publish to an MQ topic. The example is thengoing to leverage MQ Subscriptions to subscribe to that topic and route the topic to specific MQqueues that subscribers can read from.

Section 3 will provide step by step implementation for setting up this example.

3. STEP BY STEP FOR SETTING UP WMB/MQ PUB/SUB EXAMPLE

0. Pre-reqs: Our scenario depends on the following MQ queues being defined. Please createthese queues In MQ explorer or using runmqsc from command line before proceeding with thesteps.

TT.XML.EXAMPLE.PUB – Input queue for publication message flowTT.XML.EXAMPLE.INPUT – Input queue for one of our subscriber message flowTT.XML.EXAMPLE.OUT – Output queue for one of our subscriber message flowTT.XML.EXAMPLE.COPY – Queue for a second subscriber

1. Create MQ topic

Go to MQ Explorer Topic folder and create a topic called TT_XML_EXAMPLE_TOPIC. In thisexample, the topic string we will use to publish messages to is “TT_XML_EXAMPLE” You canalso give a topic a hierarchical structure using “/”. More information on this can be found in MQinfocenter document.

(http://transformatech.files.wordpress.com/2013/09/tt_xml_example_topic.jpg)

2. Create WMB Publication Flow

Next, we need to build a WMB Message Flow to publish message to the MQ Topic we setup instep one.

To build your Publication Flow, you need 2 Nodes:

(1) MQ Input Node that uses TT.XML.EXAMPLE.PUB queue and also has the “topic” propertyset to our Topic string(“TT_XML_EXAMPLE”) in the advance property tab on the MQ Input Node(see image below).

(2) Publication Node – No properties should be set on this. It will get the topic to publish tofrom MQ Input Node Topic property.

Once you deploy this message flow and it receives a message, it will start publishing messages tothe topic.

(http://transformatech.files.wordpress.com/2013/09/publication_flow_image.jpg)

3. Create Subscription to Topic

Now that we are publishing messages to a topic, we can have subscribers to subscribe to thistopic. To do this, we need to first create an MQ subscription in MQ Explorer. In this example, wewill call it “TT_XML_TO_COBOL_SUB” and setup the topic to use(TT_XML_EXAMPLE_TOPIC)and the destination to be an MQ queue called “TT.XML.EXAMPLE.INPUT”. This will be theinput to our subscriber message flow that we will create in step 4.

(http://transformatech.files.wordpress.com/2013/09/tt_xml_to_cobol_sub.jpg)

4. Create Subscription Message Flow

For this blog, we will use our previous message flow (XML TO COBOL) where an XML message ismapped to a COBOL Output. The implementation can be anything you want this subscriber todo with the message including any transformation, enrichment, and/or routing.

(http://transformatech.files.wordpress.com/2013/09/subscription_message_flow_image.jpg)

5. Create 2nd subscription to topic

For simple illustration purposes, we are going to create a second subscription to just get a copy ofthe message published to the topic. To do this, go to MQ Explorer again and create an MQSubscription called “TT_XML_COPY_SUB” using the same topic(TT_EXAMLE_XML_TOPIC) andthe destination queue to be “TT.XML.EXAMPLE.COPY”

(http://transformatech.files.wordpress.com/2013/09/tt_xml_copy_sub.jpg)

6. Testing Simple Pub/Sub Example Scenario

For our scenario, we will use RFHUtil to put a test XML message to the input queue(TT.XML.EXAMPLE.PUB) of the publication message flow.

(http://transformatech.files.wordpress.com/2013/09/original_inputmessage_image.jpg)

This XML will then get published to the topic (TT_EXAMPLE_XML_TOPIC). Our twosubscriptions will then receive this XML message and we will get the following respective outputsfrom our two subscriptions:

Output (Subscription 1):

1. Subscription sends XML to destination queue TT.XML.EXAMPLE.INPUT. The subscriptionmessage flow will process the message and send COBOL formatted message toTT.XML.EXAMPLE.OUT queue.

(http://transformatech.files.wordpress.com/2013/09/cobol_output_message.jpg)

2. The second subscription will send XML to destination queue TT.XML.EXAMPLE.COPY.

(http://transformatech.files.wordpress.com/2013/09/tt-xml-example-copy.jpg)

This concludes our blog on using WMB v7 and MQ v7 to implement a simple Pub/Sub scenario. We welcome any comments if you have any questions or want to provide feedback.

Thank you,

TransformaTech (http://www.transformatech.com)

From → Integration

13 Comments 1. DeMatrixx permalink

You incorrectly name TT.XML.EXAMPLE.PUT as input queue for the publisher flow. There isno TT.XML.EXAMPLE.PUT queue, that should be TT.XML.EXAMPLE.PUB queue

Replytransformatech permalink

You May Like

1. Why YouShould Be Drinking Lemon Water inthe Morning 3 months ago learni.stLearni.st Learni.st (sponsored)2.

You May Like

1. Why YouShould Be Drinking Lemon Water inthe Morning 3 months ago learni.stLearni.st Learni.st (sponsored)2.

You May Like

1. Why YouShould Be Drinking Lemon Water inthe Morning 3 months ago learni.stLearni.st Learni.st (sponsored)2.

You May Like

1. Why YouShould Be Drinking Lemon Water inthe Morning 3 months ago learni.stLearni.st Learni.st (sponsored)2.

About these ads (http://wordpress.com/about-these-ads/)

Thank you for your feedback. The blog has been updated.

ReplyDeMatrixx permalinkAnother correction: for the publication flow you configured the MQInput topic propertyto “TT.XML.EXAMPLE” ; that should be “TT_XML_EXAMPLE” to match the topicstring used in MQ Explorer

2. DeMatrixx permalinkWhile I’m here, I need to call a subflow with INPUT and OUTPUT nodes as my subscriberflow; how do I achieve that?

More details: I’m using WMBv8.0.02. I have a webservice with SOAPInput and SOAPOutputnodes (both in the parent/main flow). I use a RouteToLabel node to transition from main flowinto the subflow which has the Input, Compute and Output nodes only.

I’m going to add MQInput and MQOutput nodes to my subflow and configure using yourguide, hopefully that will work

Replytransformatech permalinkI am not sure how you want to use Pub/Sub from your comment. If you have a SOAPInputNode receiving messages and your flow specifically routes messages to a subflow, it doesnot require Pub/Sub.

If you are creating a new message flow with MQInput node that you want to receivepublication messages, then all you will need to do is create another MQ Subscription inMQExplorer that reads from a topic and routes that message to your queue that yourMQInput Node is reading from.

Hope this helps.

ReplyDeMatrixx permalinkThz for your reply. I was asked to create a webservice, I did that, the RouteToLabel nodeautomatically calls the subflow…pretty much what you explained above. The task nowis that they also want that same subflow to be called by a publisher flow as well –pub/sub.

Which is where I’m puzzled because I recall reading in the infocenter that for a flow tobe a subflow it must have as the ‘input node’ as it first node; not the other nodes(MQIput, SOAPInput,etc)

transformatech permalinkSorry for delayed response. You are correct, the scenario in the blog is specifically tiedusing MQ’s Pub/Sub model and requires an MQInput which would mean this may notbe a subflow. (I never tried it but you may be able to have both an Input and MQInputin your message flow that will accomplish both scenarios. You can also implement asimple subscriber message flow that reads from a queue and then uses your existingsubflow.

There are other mechanisms for implementing pub/sub with Broker but that is not atopic for this simple Pub/Sub scenarios this blog was for.

3. DeMatrixx permalinkHaving both an Input and MQInput in my subflow did not work, so I tried ‘simple subscribermessage flow that reads from a queue and then uses your existing subflow’…which makesmuch more sense. I think that’s the right layout this task.

My issue now is when I test the project as a webservice…its works perfectly; however when Iuse RHFUtil to test pub/sub nothing gets writing to my subscriber input queue. Thinkingmaybe its something with the publication node, I also test it writing the message directly to thesubscriber input queue; the message got written to queue but nothing in the output queue. Ithink there’s something fishy going on with WMB as usual because I follow your blog to the T

ReplyDeMatrixx permalinkDo I need to explicitly set the Topic in my XML message or Topic gets assigned to mymessage once it is written to TT.XML.EXAMPLE.PUB queue?

Reply4. Ashwin permalink

Please help me..,I’ve done the same steps..but not getting the output..,Please clear my below confusionsIn Topic section of publication flow..do i need to mention ‘Topic’ or ‘Topic string’ ?

How can i knw tht my data has been published..?

Once published am not able to receive at the subscribed node..neither the queue depth isincreasing…,please help me out

Replytransformatech permalinkThe publication node will get the information from the MQInut node “topic” property. Thisshould be set to “TT_XML_EXAMPLE” which refers to the Topic string.

ReplyAshwin permalinki’ve did the same…,,But the subscription queue depth remains zero…How can i debugthis please help

5. transformatech permalinkIf you want please send screen shots of each step in your setup to [email protected] we can take a quick look to see if we can see what is the problem.

Reply

Blog at WordPress.com. | The Titan Theme.

Follow

Follow “TransformaTech”

Build a website with WordPress.com