home / infca / MQ Pub/Sub v7 (navigation links) .

Pub | Sub | App | run a sample | Monitor pub/sub Misc | Links | End

MQ Pub/Sub v7

Publish/Subscribe is a term used to define an application model in which the provider of some information is decoupled from the consumers of that information.


Amunt! Top Amunt!
Concepts

Publishers and subscribers are applications that send and receive messages (publications) using the publish/subscribe method of messaging. Publishers and subscribers are decoupled from one another so that publishers do not know the destination of the information that they send, and subscribers do not know the source of the information that they receive.

The provider of the information is called a publisher. Publishers supply information about a subject without needing to know anything about the applications that are interested in the information.

The consumer of the information is called a subscriber. The subscriber decides what information it is interested in, and then waits to receive that information. Subscribers can receive information from many different publishers, and the information they receive can also be sent to other subscribers.

WebSphere MQ V7 queue managers use a Pub/Sub Engine instead of a broker to control the interactions between publishers and subscribers. The Pub/Sub Engine receives messages from publishers, and subscription requests from subscribers. The Pub/Sub Engine's job is to route the published data to the target subscribers.

mq v7.5 publib + "Publishers and subscribers"

The publisher generates a message that it wants to publish and defines the topic of the message.
A subscriber registers a request for a publication by specifying one of the following items:

Valit topic names

Non valid topic names :

TOPICSTR(DEC-00001) TOPICSTR(ALP 00002)
Publish/subscribe has been changed significantly for WebSphere MQ Version 7.0

In previous versions, publish/subscribe messaging was controlled using a command message interface. This interface is deprecated in Version 7.0 publish/subscribe. Instead, publish/subscribe messaging is now controlled using new function in the WebSphere MQ API and as a result, publish/subscribe messaging is much more consistent with point-to-point messaging. This new way of doing publish/subscribe messaging is documented in the main body of this section of the information center.
Applications written using previous versions of WebSphere MQ publish/subscribe that make use of the command message interface are encouraged to move to the new WebSphere MQ publish/subscribe API. However, the command message interface continues to be supported on all platforms (including z/OS). If you are already a user of publish/subscribe you can continue to use your current configuration after installing WebSphere MQ Version 7.0 without making extensive changes to your applications or configuration.
Similarly, JMS applications do not have to be modified, although if you do not chose to use the new Version 7.0 publish/subscribe you will not benefit from the simplified administration that is now available when using WebSphere MQ as the provider. Since the command message interface method of doing publish/subscribe is still supported in Version 7.0 using the PSMODE function, this interface continues to be documented in the WebSphere MQ Version 7.0 library.

More detail in those links

Nomenclatura

Amunt! Top Amunt!
Publish

An application that needs to publish a message about a specific topic can do so by opening that topic and putting a message to it. There is very little difference between an application that opens a queue then puts a message to it, and one that opens a topic to put a message to it, so the application code should look very familiar to you.

If you wish to use publish/subscribe with WebSphere MQ V7 you do not require any topic objects to be defined. You can in fact go right ahead and use a topic string directly in your application. You do this by placing your topic string in the ObjectString field.

TMM42

The publisher can send a Register Publisher command message to the broker's control queue SYSTEM.BROKER.CONTROL.QUEUE to indicate that a publisher will be, or is capable of, publishing data on one or more specified topics.


Amunt! Top Amunt!
Subscribe

An application that wants to register an interest in information about a certain topic needs to subscribe to that topic. This can be done using the MQ API verb MQSUB. MQSUB can be thought of rather like MQOPEN. It details the resource you wish to use, and it is the point where security checks are done.

TMM42

Subscriber applications need to register their interest in receiving publications with a broker. Send the Register Subscriber command message to the SYSTEM.BROKER.CONTROL.QUEUE to register as a subscriber.


Amunt! Top Amunt!
Distributed publish/subscribe

Concept - how does it work

Broker Network
Publish/subscribe hierarchies

Theory, sample config



Amunt! Top Amunt!
Running sample application

See sending and receiving test publications on a topic object folder (using Explorer)

The steps are :

  1. verify PSMODE for qmgr is ENABLED or code ALTER QMGR PSMODE(ENABLED) - see here

  2. establish connectivity between queue managers either
    • connecting the queue managers to a WebSphere MQ cluster
    • establishing a point-to-point channel connection using a transmission queue, or queue manager alias, with the same name as the parent queue manager

  3. connect a queue manager to a broker hierarchy using command ALTER QMGR PARENT(PARENT_QMGR_NAME)
    We can display it using display pubsub all command

  4. define topics on one broker or queue manager that are available to publishers and subscribers on the connected queue managers. This command DEFINE TOPIC (ORANGE.TOPIC) TOPICSTR (ORANGE) DEFPRTY(ASPARENT) NPMSGDLV(ASPARENT) replace defines a topic called ORANGE.TOPIC that resolves to the topic string ORANGE

    Any attribute that is set to ASPARENT uses the attribute as defined by the parent topic of this topic. This action is repeated up the topic tree as far as the root topic, SYSTEM.BASE.TOPIC is found. See Topic trees

  5. you have to register as a subscriber [cmd line ?]

    rem ---start "SUB() all publications" amqssub # QM_CNT2 start "SUB() ESPORTS publications" amqssub ESPORTS/# QM_CNT2 start "SUB() FUTBOL publications" amqssub ESPORTS/FUTBOL/# QM_CNT2 start "SUB() BCN publications" amqssub ESPORTS/+/BCN QM_CNT2

    You can now view a list of subscribers [cmd line ?]

  6. you can register as a publisher, but it not mandatory
    You can now view registered publishers [cmd line ?]

  7. now you can publish messages

    amqspub ESPORTS QM_CNT < t_tot.txt amqspub ESPORTS/FUTBOL QM_CNT < t_futbol.txt amqspub ESPORTS/FUTBOL/BCN QM_CNT < t_bcn.txt

Read writing publish/subscribe applications :

Amunt! Top Amunt!
A simple sample

We need 2 queue managers :

crtmqm -u QL.DLQ QMPUBL strmqm QMPUBL crtmqm -u QL.DLQ QMSUBS strmqm QMSUBS runmqsc QMPUBL < objectes_qm_publish.txt runmqsc QMSUBS < objectes_qm_subscribe.txt

And their objects :

$ type objectes_qm_publish.txt * set QM as FR of cluster 'CLUS_PS' ALTER QMGR REPOS('CLUS_PS') * Listener sample : starts and stops with queue manager DEFINE LISTENER ('mq_lsr_2415') TRPTYPE(TCP) PORT(2415) CONTROL(QMGR) REPLACE * define cluster channels DEFINE CHANNEL(TO.QM1) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) CONNAME('localhost(2415)') CLUSTER('CLUS_PS') replace DEFINE CHANNEL(TO.QM2) CHLTYPE(CLUSSDR) TRPTYPE(TCP) CONNAME('localhost(2416)') CLUSTER('CLUS_PS') replace $ type objectes_qm_subscribe.txt * set QM as FR of cluster 'CLUS_PS' ALTER QMGR REPOS('CLUS_PS') * Listener sample : starts and stops with queue manager DEFINE LISTENER ('mq_lsr_2416') TRPTYPE(TCP) PORT(2416) CONTROL(QMGR) REPLACE * canales de cluster DEFINE CHANNEL(TO.QM2) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) CONNAME('localhost(2416)') CLUSTER('CLUS_PS') replace DEFINE CHANNEL(TO.QM1) CHLTYPE(CLUSSDR) TRPTYPE(TCP) CONNAME('localhost(2415)') CLUSTER('CLUS_PS') replace * Topic objects are to be used for administration * and topic strings for publish messages and subscribing to publications define topic(T1) TOPICSTR('ESPORTS') CLUSTER('CLUS_PS') DURSUB(NO) replace define topic(T2) TOPICSTR('ESPORTS/FUTBOL') CLUSTER('CLUS_PS') DURSUB(NO) replace define topic(T3) TOPICSTR('ESPORTS/FUTBOL/CATALUNYA') CLUSTER('CLUS_PS') DURSUB(NO) replace

Amunt! Top Amunt!
Monitoring pub/sub

Using DISPLAY TPSTATUS TYPE(SUB) you can see the details of the current publishers on this topic string. One of the attributes returned is the Active Connection ID (ACTCONN) which links to DISPLAY CONN which shows you the details about that specific application. The Subscription ID (SUBID) links to DISPLAY SBSTATUS where we will see a single subscription with that ID since the perspective of that display is the subscription.

DISPLAY SBSTATUS which shows the run-time status of a subscription. DISPLAY SUB is slightly different it shows the more static attributes of the subscription, whether it was created using a DEFINE SUB command or an MQSUB call in an application.

dis tpstatus dis sbstatus

TMM42


Amunt! Top Amunt!
pub/sub troubleshooting

url


Amunt! Top Amunt!
Miscelaneous items
Futur del Pub/Sub

mirrorq

Queues and topics are interchangable in MQ v7. You can have the app put the message to a Topic that has two subscriber queues for the receivers, without changing the apps.


Duplicació de missatges
  1. define a topic called Q1T, with a topic string of Q1
  2. define a sub to topic object Q1T, with a destination of Q1
  3. define a Q Alias called Q1Alias, target type topic with a target of Q1T
  4. a put to Q1Alias will now produce a message to the Q1 local queue
  5. define another sub to topic object Q1T, this time with a destination of Q2
  6. a put to Q1Alias will now produce 2 messages, one to Q1 and one to Q2.

url

Define a TOPIC that acts as the destination of the sending app and two subscriptions to the "real" destination queues.

Another seq: App A is putting to a local q called Q1. App B is pulling from Q1. You have MQ 7 and want to duplicate the messages but do not want to change the sending or receiving app code.

The only change in the original setup is that App A puts to Q1Alias instead of Q1. App A and App B don't know they are using Pub Sub. The subscriptions are created by the MQ Admin using admin commands.

url


Amunt! Top Amunt!
Dubtes de pub/sub

Amunt! Top Amunt!
Links, URLs

Ep ! Valid HTML 4.01!   Valid CSS! Escriu-me !
Updated 20150904  
Uf !