Search code examples
apache-camelactivemq-classicspring-jmsspring-java-config

Two JmsComponent in One CamelConfiguration with Spring


I am using CameConfiguration to define a CamelContext as public Class Config extends CamelConfiguration and JmsComponent is defined as below:

@Bean public JmsComponent activemq(){...} and in route definition

it is used in route definition as to(activemq:queue:destinationName)

How do I define two different ActiveMQ JmsComponents as beans with Spring and use them in the same or two different routes?


Solution

  • Just add 2 methods and give each method a different name, the name of the method is the bean id by default in spring when using @Bean, eg

    @Bean 
    public JmsComponent activemq()
    
    @Bean 
    public JmsComponent activemq2()
    

    And then use activemq and activemq2 in as the component names in the Camel routes.