XMS IBytesMessage вызывает проблемы с разделенным ZIP-файлом - PullRequest
0 голосов
/ 27 января 2020

После обновления MQ до "IBM MQ Explorer V9.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, но файлы не будут правильно разархивированы.

Как ни странно, если мы используем rfhutil c .exe, мы можем вручную извлекайте файлы при условии, что мы установили параметры записи как Без заголовков и не включать MQMD - но приведенный выше код всегда работал в предыдущей версии MQ / XMS

Любая помощь, которую вы можете предоставить, будет очень признательна.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...