// TODO: generalise to a comparison of all immutable parts of messages private boolean compareMessageData(AMQPMessage m1, AMQPMessage m2) throws IOException { ByteArrayOutputStream b1 = new ByteArrayOutputStream(); ByteArrayOutputStream b2 = new ByteArrayOutputStream(); m1.getData().get(0).writeContent(new DataOutputStream(b1)); m2.getData().get(0).writeContent(new DataOutputStream(b2)); return Arrays.equals(b1.toByteArray(), b2.toByteArray()); }