Home | Previous Page | Next Page   MQ DataBlade Module > About the MQ DataBlade Module > Verification > 3 3 3

Publishing and Subscribing to a Queue

3

Publishing and subscribing to a queue 3is an effective way of exchanging information between multiple users. 3The MQ DataBlade module interacts directly with the WMQ Publish/Subscribe 3component. The component allows a message to be sent to multiple 3subscribers based on a topic. Users subscribe to a topic, and when 3a publisher inserts a message with that topic into the queue, the 3WMQ broker routes the messages to all of the queues of each specified 3subscriber. Then, the subscriber retrieves the message from the 3queue.

3

The following actions are described in this section: 3

3 3 3

Subscribing To a Queue

3

To subscribe to a queue, use the MQSubscribe() function. 3 The following example shows how a database application subscribes 3to a queue to receive messages for a topic named Weather:

3

3
   --- before subscribe
3   Topic: MQ/TIMESERIES.QUEUE.MANAGER           /StreamSupport
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3
3BEGIN WORK;
3
3EXECUTE FUNCTION MQSubscribe('AMT.SAMPLE.SUBSCRIBER', 'AMT.SAMPLE.PUB.SUB.POLICY', 
3'Weather');
3
3(expression)           1
3
31 row(s) retrieved.
3
3   --- after subscribe
3   Topic: MQ/TIMESERIES.QUEUE.MANAGER           /StreamSupport
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3   Topic: Weather
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER         /Subscribers/Identities/*
3
3COMMIT WORK;
3 3

Unsubscribing From a Queue

3

To unsubscribe from a queue, use 3the MQUnsubscribe() function, as in the following example:

3

3
BEGIN WORK;
3
3EXECUTE FUNCTION MQUnsubscribe('AMT.SAMPLE.SUBSCRIBER', 'AMT.SAMPLE.PUB.SUB.POLICY', 
3'Weather');(
3
3expression)           1
3
31 row(s) retrieved.
3   Topic: MQ/TIMESERIES.QUEUE.MANAGER             /StreamSupport
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER           /Subscribers/Identities/*
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER           /Subscribers/Identities/*
3   Topic: MQ/S/TIMESERIES.QUEUE.MANAGER           /Subscribers/Identities/*
3
3COMMIT WORK;
3 3

Publishing to a Queue

3

To publish to a queue, use the MQPublish() function, 3as in the following example:

3

3
BEGIN WORK;
3
3EXECUTE FUNCTION MQPublish('IDS.DEFAULT.SERVICE', 'IDS.DEFAULT.POLICY', 'Weather');
3
3(expression)           1
3
3COMMIT WORK;
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]