骆驼activemq组件nosuchmethod异常

时间:2018-12-21 22:13:45

标签: apache-camel camel-jms

我正在使用activemq组件发送/接收消息,但是当我split()body()时,却遇到了以下异常。 我正在使用骆驼2.23.0版本。有人可以告诉我什么地方出问题了吗?

这是导致此问题的路由的示例:

from("activemq:queue:aaa")
.process("myprocessor")
.split().body()
.to("activemq:queue:bbb")

如果使用这种方式,我没有问题:

from("activemq:queue:aaa")
.process("myprocessor")

在MyProcessor内部,

process(Exchange exchange) {
   for (String body : exchange.getIn().getBody(List.class)) {
     ProducerTemplate.sendBody("activemq:queue:bbb",body);
   }
 }

例外:

Caused by: java.lang.NoSuchMethodError: org.apache.camel.component.jms.JmsMessage.getCamelContext()Lorg/apache/camel/CamelContext;
    at org.apache.camel.component.jms.JmsMessage.newInstance(JmsMessage.java:195)
    at org.apache.camel.component.jms.JmsMessage.newInstance(JmsMessage.java:40)
    at org.apache.camel.impl.MessageSupport.copy(MessageSupport.java:152)
    at org.apache.camel.impl.DefaultExchange.copy(DefaultExchange.java:116)
    at org.apache.camel.impl.DefaultExchange.copy(DefaultExchange.java:90)
    at org.apache.camel.util.ExchangeHelper.createCopy(ExchangeHelper.java:301)
    at org.apache.camel.processor.Splitter.copyExchangeNoAttachments(Splitter.java:291)
    at org.apache.camel.processor.Splitter.access$100(Splitter.java:56)
    at org.apache.camel.processor.Splitter$SplitterIterable.<init>(Splitter.java:158)
    at org.apache.camel.processor.Splitter$SplitterIterable.<init>(Splitter.java:144)
    at org.apache.camel.processor.Splitter.createProcessorExchangePairsIterable(Splitter.java:141)
    at org.apache.camel.processor.Splitter.createProcessorExchangePairsList(Splitter.java:245)
    at org.apache.camel.processor.Splitter.createProcessorExchangePairs(Splitter.java:129)
    at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:241)

1 个答案:

答案 0 :(得分:0)

除了克劳斯·易卜生(Claus Ibsen)评论的潜在的类路径问题之外,我想知道您正在尝试实现什么。

您的MyProcessor遍历消息正文(List)的各个部分,并将每个部分发送到队列bbb。然后您在骆驼路线中使用Splitter并将零件发送到队列bbb

您的MyProcessor与其他骆驼路线一样吗?