0

我从 ServiceMix 4.4.0 中获取了简单的 activemq-camel-blueprint 示例,并添加到 Mina TCP 套接字中以从 ASCII 行中读取。

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="mina:tcp://localhost:4001?textline=true&amp;sync=false" />
        <bean ref="NMEAString" method="ingest" />
        <to uri="activemq:queue:LOG.ME"/>
    </route>
    <route>
        <from uri="activemq:queue:LOG.ME" />
        <to uri="log:ExampleActiveMQRouterBlueprint" />
    </route>
</camelContext>

我在 Karaf 中运行示例。NMEAString 所做的只是将对象打印到 STDOUT。

我运行一个小程序将 ASCII 文件推送到套接字连接。它在几毫秒内推入整个文件(〜40)行。

我在 Karaf 中看到一个 STDOUT 打印输出,行间间隔大约 30 秒。我的 servicemix.log 文件中出现以下异常:

有谁知道这个异常是什么意思以及为什么用这样一个简单的例子抛出它?

org.apache.camel.CamelException:org.apache.camel.CamelExchangeException:无法写入正文。Exchange[消息:[Body is null]] 在 org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:91)[186:org.apache.camel.camel-mina:2.8.3]在 org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:564)[187:org.apache.servicemix.bundles.mina:1.1.7.5] 在 org.apache.mina.common.support .AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)[187:org.apache.servicemix.bundles.mina:1.1.7.5] 在 org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53) [187:org.apache.servicemix.bundles.mina:1.1.7.5] 在 org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1。exceptionCaught(AbstractIoFilterChain.java:643)[187:org.apache.servicemix.bundles.mina:1.1.7.5] 在 org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224)[187:org .apache.servicemix.bundles.mina:1.1.7.5] 在 org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)[187:org.apache.servicemix.bundles.mina:1.1 .7.5] 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_29] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6 .0_29] at java.lang.Thread.run(Thread.java:662)[:1.6.0_29] 原因:org.apache.camel.CamelExchangeException:无法写入正文。在 org.apache.camel.component.mina.MinaHelper.writeBody(MinaHelper.java:55)[186:org.apache.

4

1 回答 1

0

LS,

我自己用 Apache ServiceMix 4.4.0 尝试过这个,下面的蓝图文件对我来说很好,所以我怀疑你的 bean 以某种方式使消息体无效或删除了消息体(例如,通过在 Exchange 上调用 getOut() 并创建一个空消息或其他东西像那样)。

您能否尝试从路由中删除 bean 以确保它确实是问题的原因?如果是,请随时发布 bean 本身的代码,我们可以帮助您寻找潜伏在那里的问题......

问候,

格特

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
  <route>
    <from uri="mina:tcp://localhost:4001?textline=true&amp;sync=false" />
    <to uri="log:test-read-stream"/>
    <to uri="activemq:queue:LOG.ME"/>
  </route>
  <route>
    <from uri="activemq:queue:LOG.ME" />
    <to uri="log:ExampleActiveMQRouterBlueprint" />
  </route>
</camelContext>

</blueprint>
于 2012-01-26T09:02:47.427 回答