ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Format #155

Closed Ivansamara109 closed 3 years ago

Ivansamara109 commented 3 years ago

Hello

How can I get mqrfh2.Format and MQMD.Fromat?

How can I tell one from another when I do Get form queue?

I also found out that:

I use mq-golang v5.1.2

Ivansamara109 commented 3 years ago

In ticket 106 sets as follows: md.Format = MQFMT_RF_HEADER_2 + " " but I get an header_error when I do the same

Unknown desc = MQPUT: MQCC = MQCC_FAILED [2] MQRC = MQRC_HEADER_ERROR [2142]

ibmmqmet commented 3 years ago

RFH2 structures are essentially interchangeable with message properties. It is irrelevant how the message was originally created and put to the queue - what you see when getting the message depends on the options you use for the MQGET and how the queue is configured (the PROPCTL attribute). The qmgr code will convert the message into the requested form. That might be a message with MQMD.Format=MQHRF2 followed by the RFH2 followed by the user data. Or it might be a message with MQMD.Format= with message properties accessible by a MessageHandle.

This Go package doesn't provide any special assistance for dealing with RFH2 structures (like a parser for the structure itself or the XML-like elements within it) so it's probably easier to use MsgHandle/properties approach. Though you can always build your own RFH2 processor if you want.

See the amqsprop.go sample for demonstrations of using the properties.

Ivansamara109 commented 3 years ago

what you see when getting the message depends on the options you use for the MQGET

But I don't know anything about message that I receive. So how can a set MQGET options if the message parameters is unknown?

ibmmqmet commented 3 years ago

The options to MQGET that I refer to are the ones that say whether properties are returned in an RFH2 or MsgHandle. You don't need to know how the message was put; you do need to know how you are going to process the message you receive. See the documentation on the MQGMOPROPERTIES* flags.

Ivansamara109 commented 3 years ago

I use MQGMO_PROPERTIES_IN_HANDLE and it seems that I need build my own RFH2 processor because MsgHandle/properties is not enough.

In addition in this case I can catch RFH headers(not RFH2) in message body if only RFH headers exists in an input message RFH \x02\x00\x00\x00$\x00\x00\x00\"\x02\x00\x00\xb8\x04\x00\x00 \x00\x00\x00\x00\xb8\x04\x00\x00<MessageRequest/> Is it ok when I get mqrfh2 headers in a MessageHandle?

but if other rfh2 headers exist, the body is correct