【发布时间】:2019-10-01 20:50:55
【问题描述】:
我正在使用带有内置 Camel Routes 的 ActiveMQ 代理。我想在收到事件后读取文件。
<pseudo>
from Event A
read File XY
to Event B with Body from File XY
</pseuod>
我简单地尝试根据事件从临时目录中移动文件,但只写入事件 B。日志文件中没有异常或错误消息。
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- You can use Spring XML syntax to define the routes here using the <route> element -->
<route>
<description>Example Camel Route</description>
<from uri="activemq:example.A"/>
<from uri="file://tmp/a?delete=true"/>
<to uri="file://tmp/b?overruleFile=copy-of-${file:name}"/>
<to uri="activemq:example.B"/>
</route>
</camelContext>
更新单个文件的工作解决方案:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- You can use Spring XML syntax to define the routes here using the <route> element -->
<route>
<description>Example Camel Route</description>
<from uri="activemq:example.A"/>
<pollEnrich>
<constant>file:///tmp/a?fileName=file1</constant>
</pollEnrich>
<log message="file content ${body}"/>
<to uri="activemq:example.B"/>
</route>
</camelContext>
【问题讨论】:
-
嗨!您需要使用 Poll Enrich EIP 以允许您将第二个“发件人”用作文件使用者。看这里:camel.apache.org/manual/latest/pollEnrich-eip.html
标签: apache-camel activemq