Setting camel ActiveMQ component options programmatically

Viewed 268

I'm new to camel concepts and ActiveMQ concepts. Here I want using embedded broker and added it to camel context as component. Now I want to add some component options to ActiveMQ component (such as useSingleConnection=true this is not a endpoint option it is component a option). I got that this could be achieve using spring XML. Is there way to do this programmatically?

    @Override
    public void configure() throws Exception {

            BrokerService broker = new BrokerService();
            broker.addConnector("tcp://localhost:61213");
            broker.setPersistent(true);
            broker.start();


        ConnectionFactory  connectionFactory = new ActiveMQConnectionFactory(jmsProducerEndpointConfig.getBlindAddress());

         //added componet to camle context
        getContext().addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

               from("test-jms:queue:MyQueue?autoStartup=true&allowNullBody=false")
               .process(exchange -> {
                    System.out.println(exchange.getIn().getBody());
                }).to("file://test");

        }

1 Answers

You are not far with the example you posted, something like the the code below should be enough:

ActiveMQComponent amq = new ActiveMQComponent();

//
// configure the component
//

getContext().addComponent("activemq", amq);
Related