【问题标题】:Adding and retrieving custom properties to MQ向 MQ 添加和检索自定义属性
【发布时间】:2017-06-10 00:49:16
【问题描述】:

我对整个 MQ 世界有点陌生,所以我不确定具体的技术细节。 我正在努力在 Websphere Mq 上发送带有附加数据的消息;然后,其他系统将使用额外的数据进行处理。

我正在使用以下代码向 mq 添加其他属性;这是正确的方法吗? C#中的代码

IMessage sendMsg;

IMessageProducer producer;

// Create a message ---someMessage will be a xml file
sendMsg = new IMessage(someMessage);

int fileSize= size("document.pdf"); 


//add addtional message properties
sendMsg.SetStringProperty("MessageSize",fileSize);


// Send the message
producer.Send(sendMsg);

另外,我如何查询 mq 以便获得所有这些属性以及实际消息?

任何人都可以帮忙吗?这让我转了一圈....

【问题讨论】:

    标签: c# ibm-mq


    【解决方案1】:

    是的,使用 SetStringProperty、SetBooleanProperty 等,您应该能够设置属性。为了取回属性值,您应该在收到消息后使用 msg.GetStringProperty、msg.GetBooleanProperty 等。在您的情况下,它必须类似于 msg.GetStringProperty(MessageSize)。

    【讨论】:

    • 我可以在 mq 上看到该值。有没有办法我可以将此值作为 MQGET 返回值的一部分...即`****Message properties**** MessageSize: '500' **** Message **** length - 72 bytes 00000000: 5246 4820 0200
    【解决方案2】:

    仅供参考。 MQ 知识中心充满了信息。

    这是Message 上的页面。向下滚动到“属性方法”部分。它具有从消息中检索属性的所有方法。

    【讨论】:

      猜你喜欢
      • 2015-03-09
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-14
      相关资源
      最近更新 更多