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 following method to get the subscription user data:
jakarta.jms.Message.getStringProperty(java.lang.String)
javax.jms.Message.getStringProperty(java.lang.String)
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:
![[Jakarta Messaging 3.0]](ngjm30.gif)
jakarta.jms.Message.getStringProperty(JmsConstants.JMS_IBM_SUBSCRIPTION_USER_DATA);
![[JMS 2.0]](ngjms20.gif)
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