activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <bruce.sny...@gmail.com>
Subject Re: How to insert from Java a new JMSproperty in header? setStringProperty() does not work
Date Thu, 19 Aug 2010 19:01:47 GMT
On Thu, Aug 19, 2010 at 4:46 AM, BenXS <bxstover@yahoo.co.uk> wrote:
>
> I am trying to set from a Java bean a new (additional) Property in header.
> Therefore I code (simplified) the following:
>
>
> public void pass(Message mess) {
>   ...
>   mess.setPropertiesModifiable(true);
>   mess.setStringProperty("newprop", "value123");
>   ...}
>
> But it didn't work.
>
> Compiler complains about cannot find symbol for "setPropertiesModifiable".
>
> If omit it the setPropertiesModifiable() statement then at runtime I get an
> exception
> java.jms.MessageNotWriteableException: Message properties are read only
>
> So how do I resolve that?

It looks like you are trying to modify a message that was just
received. The problem with this is that messages are immutable once
they have been sent by the producer. Also, the setPropertiesModifiable
method is not from ActiveMQ, are you using a different vendor's JMS
API? To work around this, just create a new message and copy anything
from the existing message that you need. With a new message, you will
be able to set properties without a problem.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Mime
View raw message