Ibm mq XMS iBytes消息导致拆分ZIP文件出现问题

Ibm mq XMS iBytes消息导致拆分ZIP文件出现问题,ibm-mq,xms,Ibm Mq,Xms,自从将MQ升级到“IBMMQExplorerV9.1”之后,在以前的版本中一直工作的XMS库开始表现出不同的行为 本质上,代码仍然将消息识别为IBytesMessage类型,并通过字节数组成功地将其写入文件,但文件本身(一个拆分的zip文件)无法重新构建自身 以下是该代码的主要部分: Dim FactoryFactory As XMSFactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ) 'Create

自从将MQ升级到“IBMMQExplorerV9.1”之后,在以前的版本中一直工作的XMS库开始表现出不同的行为

本质上,代码仍然将消息识别为IBytesMessage类型,并通过字节数组成功地将其写入文件,但文件本身(一个拆分的zip文件)无法重新构建自身

以下是该代码的主要部分:


Dim FactoryFactory As XMSFactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ)

            'Create a ConnectionFactory Object
            cfConnectionFactory = FactoryFactory.CreateConnectionFactory()

            'this variable will contain the full path of any file downloaded from MQ
            Dim strMQMessageOutputFileDestinationFilePath As String = ""

            'This variable will be used to evaluate whether the MQ Message Output file exists
            Dim fiMQMessageOutputFile As FileInfo = Nothing


            'Set various Connection Factory properties
            cfConnectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, Me.HostName)
            cfConnectionFactory.SetIntProperty(XMSC.WMQ_PORT, 1414)
            cfConnectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "SYSTEM.DEF.SVRCONN")
            cfConnectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, 1)


            cfConnectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, Me.QueueManager)
            cfConnectionFactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, 0)


            'Create a new Iconnection object via the Connection Factory
            connection = cfConnectionFactory.CreateConnection()

            'Create a sesion via the Connection Object, using ClientAcknowledge mode
            'ClientAcknowledge is being used because it allows us to control precisely 
            'when a message should be removed from the queue
            session = connection.CreateSession(False, AcknowledgeMode.ClientAcknowledge)


            'Create a destination using the Session Object
            destination = session.CreateQueue(Me.mstrDestinationURI)

            destination.SetIntProperty(XMSC.DELIVERY_MODE, 1)

            'Create a consumer using the Session & Destination Objects
            Consumer = session.CreateConsumer(destination)

            connection.Start()

            'IMessage is the base class that is returned from the Consumer's Receive method
            Dim recvMsg As IMessage = Nothing

            ' Retrieve message from Queue
             recvMsg = Consumer.ReceiveNoWait

                     strFileNameFromMsg = If(Not recvMsg.PropertyExists("fileName"), "",
                     recvMsg.GetStringProperty("fileName"))

                    If TypeOf (recvMsg) Is IBytesMessage Then
                        'Binary Message
                        Dim msg As IBytesMessage = CType(recvMsg, IBytesMessage)
                        Dim buffer(msg.BodyLength) As Byte

                        msg.ReadBytes(buffer)
                        Dim content As String = Text.Encoding.UTF8.GetString(buffer)

                        'The PrepareDestinationFile Function will generate a unique file name for the new file
                        'and ensure that the file does not already exist on the drive
                        strMQMessageOutputFileDestinationFilePath = PrepareDestinationFile(strFileNameFromMsg)


                        'A FileStream object is needed to write a binary array to a file
                        Dim fsZipFile As FileStream = New FileStream(strMQMessageOutputFileDestinationFilePath, FileMode.Create)

                        'Write the contents of the Byte Array to the File via the FileStream object
                        fsZipFile.Write(buffer, 0, buffer.Length)
                        fsZipFile.Close()


                    End If

因此,代码不会引发任何类型的异常-代码仍然将消息识别为IBytesMessage,但文件无法正确解压缩

奇怪的是,如果我们使用rfhutilc.exe,我们可以手动提取文件,只要我们将写选项设置为“无头”且不包含MQMD,但上面的代码在以前版本的MQ/XMS中始终有效


非常感谢您提供的任何帮助。

抱歉,澄清一下,我被告知与服务器组件相对应的客户端是:IBM MQ Explorer V9.1您可以右键单击IBM MQ dll并检查其版本。最好了解“工作”dll的版本和“非工作”dll的版本。如果这些是贵公司的内部IP,我建议您将它们编辑掉。如果您长期担心,因为即使您编辑的内容在编辑历史记录中也可用,您可以将问题标记为“需要版主干预”,并要求他们编辑您意外发布的私人信息。“IBM.XMS.dll”.NET项目引用的是9.0.0.8版。@king_moot-使用RFHUTIL将zip文件写入队列。使用使用您的代码构建的应用程序并参考MQ 9.1.4 CD发行版的IBM.XMS.DLL收到消息。我能够成功地解压文件。