代码之家  ›  专栏  ›  技术社区  ›  Arif K.

Apache Camel、IBM MQ集成

  •  1
  • Arif K.  · 技术社区  · 7 年前

    我想使用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 .

    1 回复  |  直到 7 年前
        1
  •  1
  •   Axel Podehl    7 年前

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

    如果将IBM MQ配置为JMS提供程序,我想这应该可以:

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