简体   繁体   English

IBM MQ 中的关联 ID 和消息 ID

[英]Correlation Id and Message Id in IBM MQ

For a c++ and c program, I am trying to set a value for msgId or CorrelId for a particular message in IBM MQ, that will be later put to a topic.对于 c++ 和 c 程序,我尝试为 IBM MQ 中的特定消息设置 msgId 或 CorrelId 的值,稍后将其放入主题中。 But there's an error of "Expression must be a modifiable L-value" for both the ids.但是两个 id 都存在“表达式必须是可修改的 L 值”的错误。

I defined the ids as我将 ID 定义为

MQBYTE24 MsgId;
MQBYTE24 CorrelId;

and the MQMD is defined as default:并且 MQMD 被定义为默认值:

MQMD md = {MQMD_DEFAULT};

I cannot use the #define directive as I am trying to single out a message to be put to a topic from the publisher's end.我无法使用#define 指令,因为我试图从发布者端挑出要放入主题的消息。 Receive all the messages for subscriber and check for the particular message.接收订阅者的所有消息并检查特定消息。

Is my approach of using correlIds or MsgIds correct or is there a better way for doing this?我使用 correlIds 或 MsgIds 的方法是否正确,或者有更好的方法吗?

I would expect you to have some code that looks like the following:-我希望您有一些如下所示的代码:-

memcpy(md.CorrelId, CorrelId, MQ_MSG_ID_LENGTH);

Please also remember that the message ID that you MQPUT to a topic does not end up at the subscribers.还请记住,您 MQPUT 到主题的消息 ID 不会在订阅者处结束。 A new message ID is created for each copy of the published message that is given to each subscriber.为提供给每个订阅者的已发布消息的每个副本创建一个新消息 ID。 You should use the Correlation ID instead to have it flow through to the subscriber, and ensure the subscribers are made correctly to receive the publishers correlation ID.您应该改用相关 ID 让它流向订阅者,并确保订阅者正确接收发布者相关 ID。

Read IBM MQ Little Gem #31: Publisher's CorrelId for more information about this.阅读IBM MQ Little Gem #31:Publisher's CorrelId了解更多信息。

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

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