130 MQSeries Publish/Subscribe Applications
5.2.5 Example - migration of applications using streams
An example of a publish/subscribe application using streams is the soccer
sample included in MQSeries Publish/Subscribe SupportPac.
The sample is made of two applications:
򐂰 The match simulator program (amqsgam.exe) that publishes non-retained
messages on topics Sport/Soccer/Event/MatchStarted,
Sport/Soccer/Event/ScoreUpdate and Sport/Soccer/Event/MatchEnded at
򐂰 The results service program (amqsres.exe) that subscribes to
Sport/Soccer/Event/* at stream SAMPLE.BROKER.RESULTS.STREAM and
uses some service-retained topics to handle recovery logic.
We will describe how to migrate this MQSeries Publish/Subscribe sample to
MQSeries Integrator.
Initial configuration
In order to run the sample on a queue manager hosting an MQSeries Integrator
broker, you first need to execute the following MQSC scripts that come with the
sample: amqsfmda.tst, amqsgama.tst, amqsresa.tst.
Publication messages will be sent by the game simulator to the stream queue
SAMPLE.BROKER.RESULTS.STREAM. This queue has no special meaning for
MQSeries Integrator and by default is not served by any user message flow or
internal MQSeries Integrator component.
Using the Control Center we will create a modified version of the Default
Publish/Subscribe message flow named WMQ Pub/Sub Soccer Sample, whose
input node is configured to read from the
SAMPLE.BROKER.RESULTS.STREAM queue (see Figure 5-7 and the
WMQPubSubSoccerSampleMsgFlow.xml file in the additional material
accompanying this redbook).
Chapter 5. Migration to MQSeries Integrator 131
Figure 5-7 MQSeries Pub/Sub Soccer Sample message flow MQInput node
The modified message flow is then deployed to the target broker.
Running the samples
Now we run the results service application specifying the broker to connect to
(for example, amqsres ITSOB3), using the Subscription tab in the Control Center
we can confirm the application started and successfully registered a subscription
(see Figure 5-8 on page 132).
The topic reported by the Control Center is:
added by MQSeries Integrator because the subscription came from an MQRFH
client providing a non-default value (actually
SAMPLE.BROKER.RESULTS.STREAM) for the MQPSStreamName parameter.
The results service application is now waiting for results from instances of match
simulator applications. Lets start a simulated game passing the name of two
teams and a broker (for example, amqsgam Beauxbatons Hogwarts ITSOB3).
Since messages are displayed by the match simulator,
nothing actually happens
in the results service window!
132 MQSeries Publish/Subscribe Applications
Figure 5-8 Checking results service subscription
Revising the configuration
Given that the subscription side of the application seems correct (see
Figure 5-8), we will now have a closer look at the publishing side: the match
simulator program.
We stop the message flow and start a simulated game. This way messages on
queue SAMPLE.BROKER.RESULTS.STREAM will not be consumed. Using the
MQSeries Explorer tool we browse the name/value pairs associated with one of
the messages. They look like this:
MQPSCommand Publish
MQPSPubOpts NoReg
MQPSTopic Sport/Soccer/Event/MatchStarted
Each message is a publication specifying a topic and the fact that the publisher is
not registered and a specific topic. The stream on which the message is
published is not specified in the MQRFH name value, but is implicitly determined
by the act of putting the messages to a specific queue.
When a message like this is received by MQSeries Integrator, it is treated as if
published to the default stream (MQSeries Integrator could not determine a
non-default stream name anyway), so the topic that is built for subscription
matching is:
Clearly this does not match the results service subscription on the topic:

Get MQSeries Publish/Subscribe Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.