title: How to set header to a string in java using JMS
body: <p>I am trying to set RFH2Header type to a message string. But it's not appending to the message.
  Please help. Thanks in advance!!!!
  Is My approach is correct ?? If i check in response queue, RFH Property gets added to bytes message.</p>
  
  <pre><code>String message1 = "MQ Message header test";
  Message message11 = session.createTextMessage(message1);
  
  MQRFH2 header = new MQRFH2();
  ByteArrayOutputStream out = new ByteArrayOutputStream ();
  DataOutput dout = new DataOutputStream(out);
  header.write(dout);
  byte[] outheaders = out.toByteArray();
  byte[] bArray = message1.getBytes("UTF-8");
  BytesMessage responseMessage = session.createBytesMessage(); // throws JMSException
  responseMessage.writeBytes(outheaders);
  responseMessage.writeBytes(bArray);
  responseMessage.setJMSType("MQRFH2");
  responseMessage.setJMSCorrelationID("12345678900000");
  responseMessage.setJMSDeliveryMode(2);
  responseMessage.setJMSPriority(4);
  responseMessage.setJMSReplyTo(queue);
  responseMessage.setStringProperty("JMS_IBM_Format", "MQRFH2"); 
  responseMessage.setIntProperty("JMS_IBM_Encoding", MQConstants.MQENC_NATIVE); 
  responseMessage.setIntProperty("JMS_IBM_Character_Set", 1208);
  responseMessage.setIntProperty("JMS_IBM_PutApplType", 11);
  producer.send(responseMessage);
  </code></pre>
  
  <p>My output looks like below in response queue.., Please help , how to set header to a string</p>
  
  <pre><code>00000   4D 51 20 4D 65 73 73 61--67 65 20 68 65 61 64 65  |MQ Message heade|
  00010   72 20 74 65 73 74 52 46--48 20 00 00 00 02 00 00  |r testRFH ......|
  00020   00 24 00 00 00 00 00 00--00 00 20 20 20 20 20 20  |.$........      |
  00030   20 20 00 00 00 00 00 00--04 B8                    |  .......�      |
  </code></pre>