You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by dap <de...@yahoo.com> on 2006/08/30 14:50:22 UTC
Is it possible to modify messages in Interceptor?
Hello,
I modify messages(add new properties, change body etc.) in Interceptor.
(current 4.1 snapshot)
but the consumer gets the messages still unchanged.
***
aqtivemq.xml:
<broker xmlns="http://activemq.org/config/1.0" useJmx="false">
...
<plugins>
<org.apache.activemq.broker.util.ModifyBrokerPlugin/>
</plugins>
...
</broker>
ModifyBrokerPlugin.java:
public class ModifyBrokerPlugin extends BrokerPluginSupport {
…
public void send(ConnectionContext context, Message messageSend) throws
Exception {
log.info("\n MapMessage before...: " + messageSend);
MapMessage msg = (MapMessage)messageSend;
msg.setStringProperty("foo","SUPER_FOO");
//messageSend.getMessage().setProperty("foo2","SUPER_FOO2");
log.info("\n MapMessage after...: " + messageSend); //message
has been changed
super.send(context, messageSend);
}
...
}
***
Do I miss something here?
Or could someone please provide an other idea / examle of modifying message
in a Queue?
thanks!
--
View this message in context: http://www.nabble.com/Is-it-possible-to-modify-messages-in-Interceptor--tf2189703.html#a6058250
Sent from the ActiveMQ - User forum at Nabble.com.
Re: Is it possible to modify messages in Interceptor?
Posted by James Strachan <ja...@gmail.com>.
Generally you can't easily change a message. Normally you consume the
message then send a new message. Its generally quite inefficient to
modify messages in place in the broker since it adds a massive
deserialization/serialization burden - but with some hacking it should
be possible.
On 8/30/06, dap <de...@yahoo.com> wrote:
>
> Hello,
>
> I modify messages(add new properties, change body etc.) in Interceptor.
> (current 4.1 snapshot)
>
> but the consumer gets the messages still unchanged.
>
> ***
>
> aqtivemq.xml:
>
> <broker xmlns="http://activemq.org/config/1.0" useJmx="false">
> ...
> <plugins>
> <org.apache.activemq.broker.util.ModifyBrokerPlugin/>
> </plugins>
> ...
> </broker>
>
>
> ModifyBrokerPlugin.java:
>
> public class ModifyBrokerPlugin extends BrokerPluginSupport {
> …
>
> public void send(ConnectionContext context, Message messageSend) throws
> Exception {
>
> log.info("\n MapMessage before...: " + messageSend);
>
> MapMessage msg = (MapMessage)messageSend;
>
> msg.setStringProperty("foo","SUPER_FOO");
>
> //messageSend.getMessage().setProperty("foo2","SUPER_FOO2");
>
> log.info("\n MapMessage after...: " + messageSend); //message
> has been changed
>
> super.send(context, messageSend);
>
> }
> ...
> }
>
>
> ***
>
> Do I miss something here?
>
> Or could someone please provide an other idea / examle of modifying message
> in a Queue?
>
>
> thanks!
> --
> View this message in context: http://www.nabble.com/Is-it-possible-to-modify-messages-in-Interceptor--tf2189703.html#a6058250
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/