【发布时间】: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