简体   繁体   English

如何通过 Websphere MQ API 检索 JMS 生产者设置的属性?

[英]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.我们正在尝试使用 Websphere MQ API 检索我们在消息中填充的 JMS 标头。

Right now i am using mq-all-client jars to establish the connection to the queueManagers.现在我正在使用 mq-all-client jars 来建立与 queueManagers 的连接。

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

I tried retrieving the JMS Property by :我尝试通过以下方式检索 JMS 属性:

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

I am getting a null .我得到一个null Is there a way where you establish a connection through MQ-allclients jar and still retrieve the JMS property set on the message ?有没有办法通过 MQ-allclients jar 建立连接并仍然检索消息上设置的 JMS 属性? I can retrieve the properties through a JMS Consumer but i want to get it through the MQ APIs.我可以通过 JMS 使用者检索属性,但我想通过 MQ API 获取它。

logger.info(message.getStringProperty("My_PROPERTY")); 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));
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM