gpt4 book ai didi

.net - 如何在.Net客户端接收时删除WebSphere MQ分组消息中的消息头信息

转载 作者:行者123 更新时间:2023-12-02 17:33:32 25 4
gpt4 key购买 nike

我正在尝试使用 .Net 客户端使用 native api [amqmdnet - WebSphere MQ Classes for .NET] 从远程 MQ 接收逻辑分组的消息,该消息是由 java 客户端使用 native api 放置的。

当我们获取逻辑分组的消息时,我们会在该组中的所有消息中看到一些标题信息,这些信息在每个编辑器([notepad++、editplus 等])中显示不同。

下面指定的 header 信息附加在该组中的每个逻辑消息中,例如“MDE”

我们正在使用getmessageoptionsopenoptions,如下所示,

mintMQQueueOpenOptions = IBM.WMQ.MQC.MQOO_INPUT_SHARED + IBM.WMQ.MQC.MQOO_FAIL_IF_QUIESCING
mobjMQGetMessageOptions = New MQGetMessageOptions
mobjMQGetMessageOptions.Options = IBM.WMQ.MQC.MQGMO_NO_SYNCPOINT + IBM.WMQ.MQC.MQGMO_FAIL_IF_QUIESCING
'mobjMQGetMessageOptions.Options = mobjMQGetMessageOptions.Options + MQC.MQGMO_LOGICAL_ORDER 'Or MQC.MQGMO_ALL_MSGS_AVAILABLE

用于读取该组中所有逻辑消息的代码片段,

            '=================================
' INTANTIATE THE MQ MESSAGE OBJECT
objMQMessage = New MQMessage
objMQMessage.Format = MQC.MQFMT_STRING
'=================================
' CLEAR THE MESSAGE VARIABLE
strMQMessage = ""

Do
'============================
' GET THE MESSAGE FROM THE MQ
mobjMQQueue.Get(objMQMessage, mobjMQGetMessageOptions)

'============================
' READ THROUGH THE MESSAGE
strMQMessage += objMQMessage.ReadString(objMQMessage.MessageLength)

'============================
' SET GMO.MATCHOPTIONS TO GROUP ID, INITIALLY IT WAS SET TO "MQC.MQMO_NONE"
mobjMQGetMessageOptions.MatchOptions = MQC.MQMO_MATCH_GROUP_ID

'============================
' DO UNTIL - MESSAGE IS THE LAST IN THE GROUP OR THE GROUP CONSISTS OF ONLY ONE MESSAGE.
Loop While (mobjMQGetMessageOptions.GroupStatus <> MQC.MQGS_LAST_MSG_IN_GROUP)

'====================================
' COLLECT THE MESSAGE IN AN ARRAYLIST
If Not String.IsNullOrEmpty(strMQMessage) Then objMQMessageList.Add(strMQMessage)

'============================
' COMMIT THE FETCH OPERATION
mobjMQQueueManager.Commit()

我们如何从每封邮件中删除此 header 信息?

最佳答案

MQMDE 包含存在于版本 2 MQMD 中但不存在于版本 1 MQMD 中的 MQMD 字段。信息中心主题 Overview for MQMD描述 MQMD 版本如何影响 GET 调用的行为:

On the MQGET call, if the application provides a version-1 MQMD, the queue manager prefixes the message returned with an MQMDE, but only if one or more of the fields in the MQMDE has a non-default value. The Format field in MQMD will have the value MQFMT_MD_EXTENSION to indicate that an MQMDE is present.

基于此,我建议提供版本 2 MQMD。也许这可以解决问题:

            '=================================
' INTANTIATE THE MQ MESSAGE OBJECT
objMQMessage = New MQMessage
objMQMessage.Version = 2
objMQMessage.Format = MQC.MQFMT_STRING
'=================================

由于 objMQMessage 会在连续调用中重复使用,因此您可能需要在每次 GET 之前设置版本。

IBM MQ 知识中心页面“MQMDE - Message descriptor extension > Overview for MQMDE”也提供了有关该主题的一些有用信息:

Usage: Applications that use a version-2 MQMD will not encounter an MQMDE structure. However, specialized applications, and applications that continue to use a version-1 MQMD, might encounter an MQMDE in some situations. The MQMDE structure can occur in the following circumstances:

  • Specified on the MQPUT and MQPUT1 calls
  • Returned by the MQGET call
  • In messages on transmission queues

关于.net - 如何在.Net客户端接收时删除WebSphere MQ分组消息中的消息头信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com