• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Publish Subscribe in WebSphere MQ Series

Publish/Subscribe Messaging Overview

 Publish/subscribe is the messaging oriented  equivalent of the object-oriented observer design pattern. In publish/subscribe messaging, a sender application creates a message containing the information it wants to send and assigns it a topic that denotes the subject of the information. This message is called a publication. WMQ receives the publication, recognizes the topic, and then distributes the publication to interested applications.

Pub_sub_0

Publisher (information producer)

In this component generates messages (publications) under a certain subject (topic) and sends the publications to a WMQ queue manager. A publisher knows nothing about the recipient(s) of the information.

Subscriber (information consumer/receiver)

In this component registers interest in a certain topic(s) with a WMQ queue manager. It also specifies its subscription queue name; that is, the queue where it wants to receive the messages related to this topic. The subscriber knows nothing about the information publishers(s).  A publications router: In this component passes messages from publishers to topic subscribers. Earlier WMQ versions required a broker component on top of a queue manager to enable publish/subscribe. The broker maintained topics and subscriptions, and it routed publications.  The queue manager is now responsible for topics, subscriptions, and routing publications.

Publish/subscribe access controls

A publish/subscribe system can have many publishers and many subscribers, and often, two or more queue managers communicating with one another. Also, an application can be both a publisher and a subscriber.

Publish/Subscribe using MQ Explorer

1.Create a Queue Manager:
2.Create the Queue manager name as ‘QM’.
3.Create a pub sub topic called ‘NEWS’ with topic string: NEWS, using WebSphere MQ Explorer.

Create a New Topic

1.Right-click on Topics and then select New –> Topic to start the “News” wizard.
2. Type “News” as the topic name.  This represents the WMQ administrative object used to manage the topic.

Pub_sub

3. Click Next.
4. On the topic properties page, type “News” in the Topic string field. This string is used to refer News topic.
5. Click on Finish.
6. Follow the below steps to create some more “Topics name” and “Topic Strings”.

  • Right-click Topics and then select topic name NEWS.BUSINESS and topic string NEWS/BUSINES
  • Right-click Topics and then select topic name NEWS.POLITICAL and topic string NEWS/POLITICAL.
  • Right-click Topics and then select topic name NEWS.SPORTS and topic string NEWS/SPORTS
  • Right-click Topics and then select topic name NEWS.SPORTS.CRICKET and topic string NEWS/SPORTS/CRICKET
  • Right-click Topics and then select topic name NEWS.SPORTS.FOOTBALL and topic string NEWS/SPORTS/FOOTBALL
  • Right-click Topics and then select topic name NEWS.SPORTS.FOOTBALL.CLUB      NEWS/SPORTS/FOOTBALL/CLUB

Creating a Subscription Queue

Pub_sub_susbcription_queue

Set up NEWS publications to be delivered to Subscription queues. Create two queues for the ‘NewsQ’ and ‘SportsQ’ applications.

Create a Subscription
In order to receive a topic’s publications, subscribers have to register interest in the topic. They use subscriptions to accomplish this.To create subscriptions pro-grammatically or through MQ Explorer follow the below steps.

In Queue manager “QM”, right click on Subscriptions—->New—> Subscription and name it as “Sub”.

Pub_sub_susbcription_queue_1

 

Click on Next.

Pub_sub_susbcription_queue_2

 

Pub_sub_susbcription_queue_3

 

Click on ‘General’ option on the left panel, on the right hand side click on ‘Select’ button to select the Topic Name as showed  above.

Click on “OK”

Define the Topic String based on the Topic name along with Destination Queue name.

Create the another Subscription name as ‘Sub2’ with same topic name and topic string as given in ‘Sub1’ define queue name as ‘SportsQ’  in ‘Sub2’.

Pub_sub_susbcription_queue_4

Test for Publish/Subscribe Setup

Perform the following steps to verify you have correctly completed the setup for the News topic

  • In Queue Manager ‘QM’, click on Topics.
  • In the right panel, right click NEWS/SPORTS/FOOTBALL/CLUB.Topic and select “Test Publication” to open the test window.
  • In the message data field, type “publish/subscribe test” (or any other text), click the “Publish message” button, and then click the Close button. This should distribute the message to the subscriber queues ‘NewsQ’ and ‘SprotsQ’.
  • In Queue Manager QM, click on Queues.
  • In the right panel, right click ‘NewsQ’ and select “Browse Messages.” When the browse messages window opens, search the “Message Data” column for the text you entered. You should also see the same message in ‘SprotsQ’.
Summary
Review Date
Reviewed Item
Publish Subscribe in WebSphere MQ Series
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Publish Subscribe in WebSphere MQ Series"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.