1

I try to build an xml message to inject it in IBM MQ.

The format to be used should be RFH2. Do you know, do you have any documentation about the format (xsd?) of the header?

Thank you.

Royce
  • 1,557
  • 5
  • 19
  • 44
  • 1
    An IBM MQ message is made of MQ header and MQ payload. The payload part could have any type of format such as JSON or XML. RH2 is part of MQ header and is a type of metadata. Please provide more information on why you RFH2 is being used in your scenario otherwise you can just push message to a IBM MQ queue object. – Rohan Apr 20 '20 at 15:44
  • Does this answer your question? [How to send message with RFH2 format?](https://stackoverflow.com/questions/61321214/how-to-send-message-with-rfh2-format) – JoshMc Apr 20 '20 at 18:31

1 Answers1

2

MQ's RFH2 is an extensible header consisting of a fixed-format binary structure followed by a variable portion with an XML-like syntax.

The structure is described (in basic terms) in the Knowledge Center here:

https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.ref.dev.doc/q099070_.htm

Some MQ clients (for example JMS and .NET) will automatically prefix the messages they send with an RFH2 header. If you are using one of these clients then you might not need to encode the RFH2 yourself - it will be added for you.

Do you have any more information about why the application needs an RFH2 header? The RFH2 is often used to carry message properties so you will need to ensure that you encoded these correctly if you are building your own RFH2.

If the application is using the MQ JMS or .NET client then it will be expecting the RFH2 header in the message to be formatted as described in the following topic:

https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.dev.doc/q032000_.htm

You may find the following utility program (rfhutil) helpful in understanding the RFH2 header and debugging your application:

https://github.com/ibm-messaging/mq-rfhutil

Note that the variable portion of the RFH2 header uses an XML-like syntax but does not support or understand all the features of XML, so you should not attempt to include your XML payload in the variable portion of the RFH2 header.... Instead the XML document should follow the RFH2 in the message.

One last point to note is that MQ can perform codepage conversions based on the format and CCSID of the message, but this is rarely what you want with an XML document (which typically describes the character encoding of the document it's own declaration like this: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>. I would therefore recommend that you set the Format field in the RFH2 to "MQFMT_NONE" so that the XML document is treated as binary data and not converted unnecessarily when the message is received by the MQ client.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
markp
  • 21
  • 2
  • Thank you a lot for this very detailed and helpful answer! To answer your question, no I don't know why the application needs RFH2 header. The guy in charge of the application told me "to inject message, use RFH2 format.". Information I need to provide are `format` (8 blanks), `mcd`, `jms` and `usr`. So, if I want to inject a message (with JMeter), could please show me an example of the `xml` message? Something like `
    ...
    ...`? Thank you a lot.
    – Royce Apr 20 '20 at 18:35