Moulesh Kumar
Moulesh Kumar

Reputation: 131

How to retrieve properties set by a JMS producer through Websphere MQ API?

We are trying to retrieve the JMS Headers we populate in the message using the Websphere MQ APIs.

Right now i am using mq-all-client jars to establish the connection to the queueManagers.

getOptions.options = CMQC.MQGMO_NO_WAIT + CMQC.MQGMO_FAIL_IF_QUIESCING + CMQC.MQGMO_CONVERT;

I tried retrieving the JMS Property by :

MQMessage message = new MQMessage();
queue.get(message, getOptions);
logger.info(message.getStringProperty("My_PROPERTY"));

I am getting a null . Is there a way where you establish a connection through MQ-allclients jar and still retrieve the JMS property set on the message ? I can retrieve the properties through a JMS Consumer but i want to get it through the MQ APIs.

Upvotes: 2

Views: 1737

Answers (1)

Roger
Roger

Reputation: 7476

logger.info(message.getStringProperty("My_PROPERTY"));

Well, that 'particular' named property does not exist. Don't forget, property keywords are case sensitive.

Why don't you dump all of the named properties of the message and see exactly which ones are in the message?

String propName;
Enumeration<String> props = msg.getPropertyNames("%");
if (props != null)
{
   while (props.hasMoreElements())
   {
      propName = props.nextElement();
      System.out.println("---> propName="+propName+" : " + "value="+msg.getObjectProperty(propName));
   }
}

Upvotes: 2

Related Questions