activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DanielR <romero...@gmail.com>
Subject Re: AMQ-5.2 Changing destination with Message.setDestination is not working properly
Date Mon, 23 Mar 2009 16:34:09 GMT

any help here?


DanielR wrote:
> 
> I have a main queue named QUEUE.COLOR.
> 1 Producer send a lot of messages to QUEUE.COLOR
> Messages only have "red ..." or "blue..." in their body
> 
> In trying to route the messages with "red ..." to QUEUE.RED and the
> messages with "blue..." to QUEUE.BLUE ONLY USING AN INTERCEPTOR
> 
> My problem: all messages are randomly dispatched to QUEUE.RED or
> QUEUE.BLUE
> 
> I have inspected some messages in QUEUE.RED and have their Destination
> property set to "queue://QUEUE.BLUE"   that's weird...
> 
> 
> Any clues? corrections? hints? codes?
> 
> 
> Best Regards, DR.
> 
> 
> 
> This is my code:
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.ActiveMQSession;
> import org.apache.activemq.ActiveMQConnection;
> import org.apache.activemq.broker.Broker;
> import org.apache.activemq.broker.BrokerFilter;
> import org.apache.activemq.broker.BrokerPlugin;
> import org.apache.activemq.broker.ProducerBrokerExchange;
> import org.apache.activemq.command.Message;
> import org.apache.activemq.command.ActiveMQQueue;
> import org.apache.activemq.broker.ConnectionContext;
> import org.apache.activemq.broker.region.MessageReference;
> import org.apache.activemq.command.TransactionId;
> import org.apache.activemq.command.ActiveMQDestination;
> 
> import javax.jms.TextMessage;
> import javax.jms.Session;
> import javax.jms.Connection;
> import javax.jms.Queue;
> 
> 
> public class MsgInterceptorPluginRouter2 extends BrokerFilter implements
> BrokerPlugin {
> 
>         public MsgInterceptorPluginRouter2() {
>                 super(null);
>         }
> 
>         public MsgInterceptorPluginRouter2(Broker next) {
>                 super(next);
>         }
> 
>         public Broker installPlugin(Broker broker) throws Exception {
>                 return new MsgInterceptorPluginRouter2(broker);
>         }
> 
>         public void send(ProducerBrokerExchange producerExchange, Message
> messageSend) throws Exception{
>                 String content = ((TextMessage)
> messageSend).getText().substring(0, 30) + "...";
>                
>                 String substr = content.substring(0,4);
>        
>                 if (substr.matches("red\\s*")) {
>                        
> messageSend.setDestination(this.getDestinations()[2]);
> //this.getDestinations()[2] is QUEUE.RED
>                 }
>                 else if (substr.matches("blue\\s*")) {
>                        
> messageSend.setDestination(this.getDestinations()[7]);//this.getDestinations()[7]
> is QUEUE.BLUE
>                 }
> 
>                 super.send(producerExchange, messageSend);
>         }
>        
> } 
> 

-- 
View this message in context: http://www.nabble.com/AMQ-5.2-Changing-destination-with-Message.setDestination-is-not-working-properly-tp22608408p22663865.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message