If you need more control over which services can receive any particular message, then you need to use the publish and subscribe functions.

An example of simple data publication is when one application notifies other applications about events of interest. The application does this by sending a message to a queue that is monitored by another application. The contents of the message might be either a user-defined string, composed from database columns, or a string-valued function call, or any valid expression that yields a string of the correct type.

Many subscribers can register to receive messages from multiple publishers. You can specify a topic that you can associate with your message. For example, a DB2® application can publish a message to the service point Weather. The message is Sleet, and the topic is Austin.

values DB2MQ1C.MQPublish ('Weather Bulletins','Sleet','Austin')
This notifies the interested subscribers that the weather in Austin is sleet. Subscribers register an interest in receiving this kind of information with the following statement:

values DB2MQ1C.MQSUBSCRIBE('aSubscriber', 'Austin')
When the subscriber is no longer interested in subscribing to a particular topic, that subscriber must explicitly unsubscribe by using a statement such as:

values DB2MQ1C.MQUNSUBSCRIBE('aSubscriber','Austin')