ActiveMQ 5.0's QueueReceiver seems to have problems with MapMessage. It
always returns bull object when the timeout occurs or waits in a countless
time.

Receiver code

QueueConnectionFactory connFactory = new
ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
QueueConnection conn = connFactory.createQueueConnection();

// This session is not transacted, and it uses automatic objectMessage
acknowledgement
QueueSession session = conn.createQueueSession(false,
QueueSession.AUTO_ACKNOWLEDGE);

// create destination
queue = session.createQueue("TestQueue");
QueueReceiver receiver = session.createReceiver(queue);

MapMessage message = (MapMessage) receiver.receive(8000);

 if (message instanceof MapMessage) {
            int age = message.getInt("age");
            float weight = message.getFloat("weight");
            String name = message.getString("name");
            String height = message.getObject("height").toString();
............
} else {
            System.out.println("Timeout!!!!!");
}

Sender code 

QueueConnectionFactory connFactory = new
ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
QueueConnection conn = connFactory.createQueueConnection();
QueueSession session = conn.createQueueSession(false,
QueueSession.AUTO_ACKNOWLEDGE);

queue = session.createQueue("TestQueue");
QueueSender sender = session.createSender(queue);

MapMessage mapMessage = session.createMapMessage();
mapMessage.setInt("age", 88);
mapMessage.setFloat("weight", 234);
mapMessage.setString("name", "Smith");
mapMessage.setObject("height", new Double(150.32));
       
System.out.println("Sending the object message: " + mapMessage.toString());
sender.send(mapMessage);

Sender run smoothly because I checked its message in queue with ActiveMQ's
web console and see the message there. But when I run the receiver to get
the message, it does not work. ActiveMQ works fine with TextMessage.

I dont know if there is anything wrong with ActiveMQ 5. I would be grateful
if someone could point me the right direction

-- 
View this message in context: 
http://www.nabble.com/Can-not-receive-MapMessage-in-ActiveMQ-5.0-tp14546105s2354p14546105.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to