Java 以编程方式设置ActiveMQ组件选项
我不熟悉camel概念和ActiveMQ概念。这里我想使用嵌入式代理,并将其作为组件添加到camel上下文中。现在我想向ActiveMQ组件添加一些组件选项(例如Java 以编程方式设置ActiveMQ组件选项,java,apache-camel,activemq,Java,Apache Camel,Activemq,我不熟悉camel概念和ActiveMQ概念。这里我想使用嵌入式代理,并将其作为组件添加到camel上下文中。现在我想向ActiveMQ组件添加一些组件选项(例如useSingleConnection=true这不是端点选项,而是组件选项)。我知道这可以通过使用SpringXML来实现。有没有办法通过编程实现这一点 @Override public void configure() throws Exception { BrokerService bro
useSingleConnection=true
这不是端点选项,而是组件选项)。我知道这可以通过使用SpringXML来实现。有没有办法通过编程实现这一点
@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");
}
您对发布的示例还不了解,下面的代码就足够了:
ActiveMQComponent amq = new ActiveMQComponent();
//
// configure the component
//
getContext().addComponent("activemq", amq);