ActiveMQDestination destination = new ActiveMQQueue("testQ");
MessageConsumer consumer = session.createConsumer(destination);
connection.start();
MessageProducer producer = session.createProducer(destination);
final MyObject obj = new MyObject("A message");
ActiveMQObjectMessage m1 = (ActiveMQObjectMessage)session.createObjectMessage();
m1.setObject(obj);
producer.send(m1);
ActiveMQTextMessage m2 = new ActiveMQTextMessage();
m2.setText("Test Message Payload.");
producer.send(m2);
ActiveMQMapMessage m3 = new ActiveMQMapMessage();
m3.setString("text", "my message");
producer.send(m3);
Message m = consumer.receive(maxWait);
assertNotNull(m);
assertEquals(m1.getMessageId().toString(), m.getJMSMessageID());
assertTrue(m instanceof ActiveMQObjectMessage);
if (getDefaultPolicy() != null) {
assertNull("object data cleared by reduceMemoryFootprint (and never marshalled as using mem persistence)",
((ActiveMQObjectMessage)m).getObject());
}
// verify no serialisation via vm transport
assertEquals("writeObject called", 0, obj.getWriteObjectCalled());
assertEquals("readObject called", 0, obj.getReadObjectCalled());
assertEquals("readObjectNoData called", 0, obj.getReadObjectNoDataCalled());
m = consumer.receive(maxWait);
assertNotNull(m);
assertEquals(m2.getMessageId().toString(), m.getJMSMessageID());
assertTrue(m instanceof ActiveMQTextMessage);