public void testChangeMutableObjectInObjectMessageThenRollback() throws Exception { ArrayList<String> list = new ArrayList<String>(); list.add("First"); Message outbound = session.createObjectMessage(list); outbound.setStringProperty("foo", "abc"); beginTx(); producer.send(outbound); commitTx(); LOG.info("About to consume message 1"); beginTx(); Message message = consumer.receive(5000); List<String> body = assertReceivedObjectMessageWithListBody(message); // now lets try mutate it try { message.setStringProperty("foo", "def"); fail("Cannot change properties of the object!"); } catch (JMSException e) { LOG.info("Caught expected exception: " + e, e); } body.clear(); body.add("This should never be seen!"); rollbackTx(); beginTx(); message = consumer.receive(5000); List<String> secondBody = assertReceivedObjectMessageWithListBody(message); assertNotSame("Second call should return a different body", secondBody, body); commitTx(); }