Hi there,
Apart from the question why you want to do such a thin in an
interceptor instead of
using virtual destinations or a camel route....
Could you share your activemq.xml to let us see how you hooked in the
plugin in the broker ?
Perhaps you could include some logging statements in your code and
understand what is executed.
You could also attach a remote debugger to Activemq and debug through
your code.
Best regards
Andreas
On Mar 23, 2009, at 5:35 PM, DanielR wrote:
>
> 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.
>
---
Mit freundlichen Grüssen - Kind Regards
Andreas Gies
Principal Consultant
Open Source Center of Competence
Progress Software GmbH
Agrippinawerft 26
50678 Köln
E-Mail agies@progress.com
Direct Line +49 (0)9953 980349
Mobile +49 (0)170 5759611
Skype +44 (0)20 3239 2922
Skype +353 (0)1 443 4971
Skype +1 (0)781 262 0168
http://www.progress.com
http://fusesource.com
http://open-source-adventures.blogspot.com
-------------------------------------------------------
Progress Software GmbH
Sitz der Gesellschaft: Agrippinawerft 26, 50678 Koeln;
Niederlassung: Fuerstenrieder Str. 279, 81377 Muenchen
Amtsgericht Koeln, HRB 15620;
Geschaeftsfuehrung: David Ireland
-------------------------------------------------------
|