MQSeries overview  Syntax for topics

Chapter 2: Understanding Real Time Messaging Services

MQSeries publish/subscribe

WebSphere MQSeries publish/subscribe is on MQSeries queues that employ a broker process to perform subscription resolution. In its simplest form:

Subscribers register “subscriptions,” which means it is interested in one or more “topics”.

Example

This example, which shows the MQ pub/sub process, uses these variables:

declare @BROKER    varchar(100)�
declare @STREAM    varchar(100)�
declare @SUBQ      varchar(100)�
declare @QM	        varchar(100)�
select @QM         = 'ibm_mq:chnl1/tcp/host1(9876)?qmgr=QM'�
select @BROKER     = 'SYSTEM.BROKER.CONTROL.QUEUE'
select @STREAM     = 'ANIMALS'
select @SUBQ       = 'MY_ANIMALS'

  1. ��Publisher registers to send publications to ANIMALS with topics on fish:�

    select msgsend(NULL,
             @QM + ',queue=' + @BROKER�
             option 'rfhCommand=registerPublisher'�
             message header 'topics=fish,streamName=' + @STREAM)�
    

  2. Subscriber registers to receive publications published to ANIMALS with topics on fish. The subscriber receives the publications on MY_ANIMALS.:

    select msgsend(NULL,�
             @QM + ',queue=' + @BROKER�
             option 'rfhCommand=registerSubscriber'�
             message header 'topics=fish'�
                             + ',streamName=' + @STREAM�
                             + ',queueName=' + @SUBQ’)
    ��
    
  3. Publisher publishes publication to ANIMALS about fish. The MQ pub/sub broker automatically forwards the publication to MY_ANIMALS:

    �select msgsend('something about fish',�
             @QM + ',queue=' + @STREAM�
             option 'rfhCommand=publish'�
             message header 'topics=fish')
    �
    
  4. Subscriber reads the forwarded message from MY_ANIMALS:

    select msgrecv(@QM + ',queue=' + @SUBQ option 'timeout=30ss')
    

Figure 2-1 shows the flow of the sample MQ pub/sub process.

Figure 2-1: The MQ publication/subscription process

A message can have one or more topics. WebSphere MQSeries pub/sub recommends that topics use a hierarchical naming convention as in the examples show below. Subscribers can specify wildcards (such as * and ?) when specifying topics of interest. These are examples of topics:

Sport
Sport/Soccer
Sport/Tennis

These are examples of how subscribers can specify topics of interest:

     Sport/*           - Any topic about sports.
     */Soccer          - Any topics about soccer.
     */Soccer/Trades   - Any topics about soccer where a 'trade' is involved.

A retained publication is a type of publication where the MQ pub/sub broker maintains a copy of a message even after it has delivered it to all subscribers. Normally, a publication is deleted after a copy has been delivered to all subscribers. A retained publication allows a subscriber to asynchronously request the retained publication instead of relying on it being delivered by the MQ pub/sub broker. These types of messages normally contain state information, and are also referred to as state publications.





Copyright © 2005. Sybase Inc. All rights reserved. Syntax for topics

View this book as PDF