Lab 3
Lab 3
MQ ▴
Overview (mq_basic_pot_overview.html)
MQ High Availability ▾
MQ AMS ▾
MQ LDAP ▾
MQ MFT ▾
MQ Salesforce Bridge ▾
MQ Telemetry ▾
MQ on Cloud ▾
MQ on IBM Cloud Private ▾
Event Streams ▾
IBM MQ Appliance ▾
You will be working with the hierarchical structure of TOPIC STRINGS represented in the picture below.
Note:
The following instructions assume that you are using the same demo environment from Lab 1. In this
case you have created the MQPOT queue managers. If the MQPOT queue manager does not appear in
the MQ Explorer, you must create it according to the instructions in Lab 1.
1. If the MQ Explorer is not already running, you can launch it from the shortcut on the desktop.
3. Click the Topics folder in the Navigator pane (left side). Notice that you have no topic objects defined
yet! We have provided a script for this purpose.
4. To run the provided script, find the shortcut called PubSub Lab Setup on the Windows 10 desktop.
Double-click the shortcut to run the script.
If you receive an Open File – Security Warning popup, click Run to allownthe script to execute.
5. The script should run very quickly, leaving the following command window open. Verify that the
command was successful. Then press Enter to close the command window.
6. You should now see the following MQ Topic objects displayed in the Content pane in the MQ Explorer.
Observe the Topic objects (under the Topic name column) and their corresponding Topic string values.
Also observe the Publish and Subscribe enablement status on the right.
13. Back in the MQ Explorer, right click Topics (under MQPOT) and then select Status.
14. Now click the “+” symbol to the left of finance – a level of the hierarchy opens; repeat on the “+” in
front of cash, then gettingit, then frombanks which is the bottom of the “tree”.
In the Topic Status notice that all the intermediate nodes have been created and that they have
inherited properties from the parent finance. These intermediate nodes have no related Topic Objects
and so cannot have their properties altered by MQSC or MQ Explorer.
1. You will now be working with some pre-defined topics. From the MQ Explorer, display topic status by
right-clicking the Topics folder and selecting Status…
2. You are going to focus on the sport topic tree. Expand the “+” symbols on the sport topic tree and
you should see something similar to the screen capture below. Notice that Publish is allowed for the
topic string sport/football/results/hursley. Also, following the tree “up”, you should notice that the
topic string sport/football has the publish attribute Inhibited. Remember this as you complete the
next steps of this lab. Click Close to dismiss the status window.
3. Start a test subscription window by right-clicking Topics and selecting Test Subscription.
4. Type in the topic string sport/football/# and press the Subscribe button. The “#” symbol is called the
multi-level wildcard. The string sport/football/# indicates a subscription to all publications sent to the
sport/football topic or any of its children. The Test Tool window remains open and the Unsubscribe
button becomes active. Publications received will be displayed in the Messages received box.
5. Minimize the Subscribe window by clicking the minimize button.
6. The Subscribe window will “park” itself at the bottom left part of the Windows desktop. You will
restore this window in a later step of this lab.
9. From the Topic display, select the SPORT.FOOTBALL row, right-click and select Topic Status –
Subscribers. This gives detailed information about subscribers to this Topic object.
10. Observe the detailed display and then close the status screen by clicking the Close button.
11. Now you will publish a message. Returning to the Topic list, select the SPORT.FOOTBALL row, right-
click and then select Test Publication.
12. This dialog will publish a message to the topic string sport football.
13. Before entering a message and sending it, you will arrange the windows on the screen.
14. Locate the Subscribe Test Tool window where you previously subscribed to sport/football/#. Click
the Restore window button to restore the window.
15. Now position the Publish Test Message and the restored Subscribe test tool windows so they both
are visible. Then return focus to the Publish window.
16. Type a message such as Hello World and then press Publish Message.
17. An error occurs and a pop-up shows you the return code 2051. You can click Details but that does not
provide any further explanation.
18. Open a command prompt, type mqrc 2051 and hit enter. You can see that 2051 indicates that put is
inhibited.
This because the topic object for sport/football is publish-inhibited. You’ll recall that we saw that this
was set earlier in the lab. But this will not inhibit our subscribers; we used the multi-level wildcard to
subscribe to topics at and below “sport/football” in the topic tree, so we will be subscribing to items
published lower in the hierarchy.
20. In the Publish Test Message window, overtype the topic string to sport/football/news/hursley and
click Publish message. You have published and subscribed your first message!
Note:
Dynamically Created Topic Objects. These dynamically created Topic objects are temporary and
only exist for a limited amount of time before the Queue Manager removes them; for example if
you restart the Queue Manager, they will no longer exist..
23. Return to the Topic object display. Once again open the Topic status list and expand the sport
hierarchy. You will see the automatically created elements. Click Close to close the status window.
This concludes this portion of Lab 3.
Administered Subscriptions
While it is typical for subscribers to register their own subscriptions, it is possible to administratively register
a subscription using MQ Explorer. This is a subscription to a topic string that delivers messages to a queue.
This can be very useful because it is a way for a legacy program which was designed as a point-to-point
application to read a queue associated with a topic; in this way it can participate in publish/subscribe
without changing the program. You will now explore how such a subscription can be set up and used.
1. In the MQ Explorer, select Queues. Right-click and select New Local Queue.
6. Leave the Topic Name blank, and enter sport/football/# as the Topic string. Leave the Destination
Queue Manager blank and enter ALL_FOOTBALL_Q in the Destination Name. Then click Finish.
This subscription will now route all qualifying messages to the local queue ALL_FOOTBALL_Q.
1. A folder on the desktop contains four shortcuts that will start two instances of a publishing sample
and two subscribers. Open the folder and then double-click each shortcut to launch the programs.
If you receive an Open File – Security Warning, click Run or Yes to allow the program to run.
2. Arrange the windows as shown, so that you can see all of them at them same time. The top two
windows are the topic publishers (amqspub) Each time you type text into either window, the windows
on the bottom, the topic subscribers (amqssub) will receive the text as published messages because
the topic string that they are subscribing to matched the one being used by the publishers.
Note:
Subscriber Timeout. The amqssub program times out after 30 seconds if no messages arrive. If
your window times out, just double-click the command again to restart the program…
3. Now in the top left window (publishing to sport/football/news/hursley) enter “test message 1” and
press Enter. The message should appear in both subscribing windows because the published
message matched both subscriptions.
Again in the top left window type the text Hursley News and then press Enter.
In the top right window type the text Football News and press Enter. Notice that the sport/football/#
subscription gets both publications. This is because when you subscribed you used a multi-level
wildcard (#) to indicate that you were interested in messages published to the sport/football topic or
any of its children, so you will get both messages.
4. Return to the Subscriptions view in the MQ Explorer. Select the ALL_FOOTBALL_SUB subscription,
right-click and select Status.
5. The message count should have a count of the messages that were published on this topic. Click
Close to close the status window.
7. You should see three messages on the queue (or as many as you put in the amqspub test). Select one
of the messages, right-click and choose Properties.
8. Click the Named Properties tab. From this display you can see the originating topic string.
9. Close the four or five open command windows as you will no longer need them.