+

Search Tips | Advanced Search

Retrieval of subscription user data

If the messages that an IBM MQ classes for JMS application is consuming from a queue are put by an administratively defined durable subscription, the application needs to access the user data information that is associated with the subscription. This information is added to the message as a property.

When a message is consumed from a queue that contains an RFH2 header with the MQPS folder, the value that is associated with the Sud key, if it exists, is added as a String property to the JMS Message object returned to the IBM MQ classes for JMS application. To enable the retrieval of this property from the message, the constant JMS_IBM_SUBSCRIPTION_USER_DATA in the JmsConstants interface can be used with the method javax.jms.Message.getStringProperty(java.lang.String) to get the subscription user data.

In the following example, an administrative durable subscription is defined by using the MQSC command DEFINE SUB:
DEFINE SUB('MY.SUBCRIPTION') TOPICSTR('PUBLIC') DEST('MY.SUBSCRIPTION.Q') 
USERDATA('Administrative durable subscription to put message to the queue MY.SUBSCRIPTION.Q')
Copies of messages that are published to the topic string PUBLIC are put to the queue, MY.SUBSCRIPTION.Q. The user data that is associated with the durable subscription is then added as a property to the message, which is stored in the MQPS folder of the RFH2 header with the key Sud. The IBM MQ classes for JMS application can call:
javax.jms.Message.getStringProperty(JmsConstants.JMS_IBM_SUBSCRIPTION_USER_DATA);
The following String is then returned:
Administrative durable subscription to put message to the queue MY.SUBSCRIPTION.Q
. Parent topic: Writing IBM MQ classes for JMS applications


Related concepts


Related information

Last updated: 2020-10-04