You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by pcdinh <pc...@gmail.com> on 2007/12/30 11:44:08 UTC
Can not receive MapMessage in ActiveMQ 5.0
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.
Re: Can not receive MapMessage in ActiveMQ 5.0
Posted by James Strachan <ja...@gmail.com>.
Could you create a JUnit test case reproducing this?
BTW you have started your connection right?
http://activemq.apache.org/i-am-not-receiving-any-messages-what-is-wrong.html
On 30/12/2007, pcdinh <pc...@gmail.com> wrote:
>
> 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.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com