MessageProducer prod = sess.createProducer(queue);
prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
MapMessage m = sess.createMapMessage();
JBossMessage check1 = ((MessageProxy)m).getMessage();
m.setString("map_entry", "map_value");
m.setStringProperty("property_entry", "property_value");
m.setJMSReplyTo(new JBossQueue("wibble"));
JBossMessage check2 = ((MessageProxy)m).getMessage();
checkSameUnderlyingMessage(check1, check2, true);
checkSameBody(check1, check2, true);
prod.send(m);
JBossMessage check3 = ((MessageProxy)m).getMessage();
//Underlying message should be the same before and after
checkSameUnderlyingMessage(check2, check3, true);
checkSameBody(check2, check3, true);
prod.send(m);
JBossMessage check4 = ((MessageProxy)m).getMessage();
assertFalse(check3.getMessageID() == check4.getMessageID());
//The underlying message should now be different
checkSameUnderlyingMessage(check3, check4, false);
//But the body should be the same
checkSameBody(check3, check4, true);
prod.send(m);
JBossMessage check5 = ((MessageProxy)m).getMessage();
// The message should be different
assertFalse(check4.getMessageID() == check5.getMessageID());
checkSameUnderlyingMessage(check4, check5, false);
//But the body should be the same
checkSameBody(check4, check5, true);
//Now set another header
m.setJMSType("type123");
JBossMessage check6 = ((MessageProxy)m).getMessage();
//The message should be different
checkSameUnderlyingMessage(check5, check6, false);
//But the body should be the same
checkSameBody(check5, check6, true);
prod.send(m);
JBossMessage check7 = ((MessageProxy)m).getMessage();
//The message should be the same
checkSameUnderlyingMessage(check6, check7, true);
// But the body should be the same
checkSameBody(check6, check7, true);
// Set the body
m.setString("key1", "blah");
JBossMessage check8 = ((MessageProxy)m).getMessage();
//The message should be the same