Apache Camel、IBM MQ 集成

Apache Camel, IBM MQ integration

我想使用 Apache Camel 在 IBM MQ 上发送消息,所以我写了一个简单的程序,但出现错误:

Exception in thread "main" org.apache.camel.NoSuchEndpointException: No endpoint could be found for: queuename, please check your classpath contains the needed Camel component jar.
    at org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:499)
    at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:167)

我的代码:

CamelContext context = new DefaultCamelContext();

//added that line after some checks but didnt help
context.addComponent("http", new HttpComponent());

 context.addComponent("test-jms",connFactory);

ProducerTemplate template = context.createProducerTemplate();

context.start();

template.sendBody("testQueueName", "Test  Message ");

testQueueName 持有 queuename.

我的 pom.xml 中有所有必要的依赖项。

sendBody() 的第一个参数必须是 Apache Camel 端点,例如 "activemq:MyQueue"。换句话说,它必须是以下之一:http://camel.apache.org/uris.html

如果您将 IBM MQ 配置为您的 JMS 提供者,我想这应该可行:

template.sendBody("jms:queue:testQueueName", "Test  Message ");