【问题标题】:Setting camel ActiveMQ component options programmatically以编程方式设置骆驼 ActiveMQ 组件选项
【发布时间】:2020-12-09 08:47:57
【问题描述】:

我是骆驼概念和 ActiveMQ 概念的新手。在这里,我想使用嵌入式代理并将其作为组件添加到骆驼上下文中。现在我想为 ActiveMQ 组件添加一些组件选项(例如 useSingleConnection=true 这不是端点选项它是组件选项)。我知道这可以使用spring XML来实现。有没有办法以编程方式做到这一点?

    @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");

        }

【问题讨论】:

    标签: java apache-camel activemq


    【解决方案1】:

    您发布的示例并不远,类似下面的代码应该足够了:

    ActiveMQComponent amq = new ActiveMQComponent();
    
    //
    // configure the component
    //
    
    getContext().addComponent("activemq", amq);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      • 2013-01-24
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多