1

I am creating a JMS route programatically by following code :

from("jms:queue:OUTBOUND_QUEUE?concurrentConsumers=5&messageListenerContainerFactoryRef=msgListenerContainerFactory").processRef("mqprocessor");

I have class :

public class MessageListenerContainerFactoryImpl implements MessageListenerContainerFactory {

        @Override 
        public AbstractMessageListenerContainer createMessageListenerContainer( 
                        JmsEndpoint endpoint) { 
        } 
}

I want to exchange some information/parameter between the above route and endpoint. And based on the parameter value I want choose the connection factory to be set in this message listener container.

Please let me know if I was able to explain my problem statement.

Is there any other way to achieve this? I want build connectionfactory at runtime and so do route. Is there any method in JmsEndpoint which I can leverage to know route-id?

Ravi Joshi
  • 103
  • 11

1 Answers1

0

I would create such a route in a method, supply the MLC as a parameter, then when needed, remove that route gracefully and recreate it with new parameters. Changing the parameters does not really make much sense.

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • Thank you for the reply Peter. I have question, JMS route just takes spring bean reference and not object reference, so how should I be passing MLC as parameter? Could you please elaborate with some example. Also in above case, MLCFactory would be invoked at time of route initialization. All I am trying to understand in from JmsEndpoint is which route has called invoked this method so that I can reply with appropriate MLC object. My MLC would change based on which route is invoking it. – Ravi Joshi May 22 '14 at 14:53
  • I really don't understand what you are up to by setting MLC at runtime, but anyway - yes - they have to be in the Camel registry, which in your case seems to be the spring context. Here is some info on the topic: http://stackoverflow.com/questions/4540713/add-bean-programatically-to-spring-web-app-context – Petter Nordlander May 23 '14 at 05:50