0

I have to inject a message in IBM MQ.

Could you please explain me how to add a custom information in the header?

Please find below how I defined the RFH2 header and the message.

def message = new MQMessage()
def rfh2 = new MQRFH2()
rfh2.setEncoding(CMQC.MQENC_NATIVE)
rfh2.setCodedCharSetId(CMQC.MQCCSI_INHERIT)
rfh2.setFormat(CMQC.MQFMT_NONE)
rfh2.setNameValueCCSID(1208)
rfh2.setFieldValue('mcd', 'Msd', 'jms_byte')
rfh2.setFieldValue('usr', 'Sender', 'mysender')
rfh2.write(message)

message.writeString(mymessage)

message.format = CMQC.MQFMT_RF_HEADER_2

And I would like to add type information. So the expected result is type='mytype'.

There is a way, a method to do that please? I checked on the doc but I didn't found information.

Thank you for help. Regards.

Royce
  • 1,557
  • 5
  • 19
  • 44

1 Answers1

3

If you want to add a property to a message then you put it in the 'usr' (user) folder.

i.e.

rfh2.setFieldValue('usr', 'type', 'mytype');

Now, if you want to pass information that either (1) is NOT going to be consumed by a JMS application or (2) you want it to be unavailable to the JMS application then use your own folder.

i.e.

rfh2.setFieldValue('royce', 'type', 'mytype');

JMS framework will only handle/use values from 3 folders: 'mcd', 'jms' and 'usr'. Supposedly, 'mqext' folder gets processed by the JMS framework but I have never been able to get it to work.

Roger
  • 7,062
  • 13
  • 20