activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DanielR <romero...@gmail.com>
Subject Re: Problem trying to route with Interceptors
Date Mon, 23 Mar 2009 16:35:07 GMT

any ideas?



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: 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]);
> 		}
> 		else if (substr.matches("blue\\s*")) {
> 			messageSend.setDestination(this.getDestinations()[7]);
> 		}
> 
> 		super.send(producerExchange, messageSend);
> 	}
> 	
> }
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-trying-to-route-with-Interceptors-tp22606463p22663866.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message