activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: NullPointerException when trying to set String propertyu
Date Thu, 01 Feb 2007 17:04:28 GMT
It looks like the property is not being sent. Typically when you
receive a message its meant to be read only - and you are generally
meant to create a new message for sending.

It could be that there is a bug when you try mutating a message and
then sending it on. (A JUnit test case proving this fact would assist
us in fixing it).
http://activemq.apache.org/contributing.html

Failing that you could try just creating a new message instead; or
using this helper method to clone the message first before mutating it

http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/command/ActiveMQMessage.html#copy()

outboundMessage = ((ActiveMQMessage) inboundMessage).copy();
outboundMessage.setStringProperty("WHATEVER", "ABC");
foo.send(outboundMessage, someTopic);


On 2/1/07, miniman <benjamin.cuthbert@db.com> wrote:
>
> All i am trying to put in a string property on my published messages that i
> can group messages together, so that when messages come into the receiver i
> can check what type of message it is, and filter on them.
>
> When i try this i get this error.
>
>         Message message = null;
>                         ObjectMessage objMSG = (ObjectMessage)message;
> objMSG.setObject(newMsgObj);
>                                 objMSG.setStringProperty("ALERTTYPE", "NEW");
> remote.send(objMSG, new ActiveMQQueue("Test"));
>
>
> 766 [ActiveMQ Session Task] WARN org.apache.activemq.ActiveMQMessageConsumer
> - Exception while processing message: java.lang.NullPointerException
> java.lang.NullPointerException
>         at
> com.db.abmonitor.client.dataimporter.ConsumerTool.onMessage(ConsumerTool.java:145)
>
> So when i look at that code i have
>
>                         if (message instanceof ObjectMessage) {
>                                 ObjectMessage objMsg = (ObjectMessage)message;
>                                 //eventMSG = (MonitorMSG)objMsg.getObject();
>                                 if(objMsg.getStringProperty("ALERTTYPE").equals("ACK"))
{
>                                         // process the ack.
> --
> View this message in context: http://www.nabble.com/NullPointerException-when-trying-to-set-String-propertyu-tf3154471.html#a8747103
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message