我正在尝试使用骆驼从JBoss EAP 7.0连接到JMS队列。我使用Java DSL而不是Spring。如何获取JNDI条目并创建连接以侦听或调度消息?以下是我通常用于连接到ActiveMQ
的代码段!
CamelContext context = new DefaultCamelContext();
context.addComponent("activemq", ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:writeQueue").to("activemq:queue:FOO");
}
});
context.start();
Thread.sleep(2000);
ProducerTemplate producer = context.createProducerTemplate();
producer.sendBody("activemq:queue:FOO", "Test Message");
我尝试添加如下代码:
CamelContext context = null;
@Resource(mappedName = "java:/jboss/exported/jms/queue/TestQ")
private ConnectionFactory connectionFactory;
public void testJMS() throws Exception {
context = new DefaultCamelContext();
JmsComponent component = new JmsComponent();
component.setConnectionFactory(connectionFactory);
context.addComponent("jms", component);
/*
Routing Section
*/
}
但是此代码给了我类似[connectionFactory must not be null
]的错误>
我正在尝试使用骆驼从JBoss EAP 7.0连接到JMS队列。我使用Java DSL而不是Spring。如何获取JNDI条目并创建连接以侦听或调度消息?以下是...
这是我在JBoss ... Wildfly中所做的工作: