Camel (2.11.0) を使用して、次の機能を実現しようとしています。
- ファイルが特定の場所に存在する場合は、それを別の場所にコピーしてから処理を開始します
- そのようなファイルが存在しない場合、ファイルのコンシューマー/ポーラーをブロックしたくありません。
direct:cleanup
ルートまで処理を続けたいだけ
ファイルを一度だけポーリングしたい!
これが私がこれまでに持っているものです(Spring XMLを使用):
<camelContext id="my-camel-context" xmlns="http://camel.apache.org/schema/spring">
<route id="my-route
<from uri="file:///home/myUser/myApp/fizz?include=buzz_.*txt"/>
<choice>
<when>
<!-- If the body is empty/NULL, then there was no file. Send to cleanup route. -->
<simple>${body} == null</simple>
<to uri="direct:cleanup" />
</when>
<otherwise>
<!-- Otherwise we have a file. Copy it to the parent directory, and then continue processing. -->
<to uri="file:///home/myUser/myApp" />
</otherwise>
</choice>
<!-- We should only get here if a file existed and we've already copied it to the parent directory. -->
<to uri="bean:shouldOnlyGetHereIfFileExists?method=doSomething" />
</route>
<!--
Other routes defined down here, including one with a "direct:cleanup" endpoint.
-->
</camelContext>
上記の設定では、 にファイルがない場合/home/myUser/myApp/fizz
、Camel はファイルができるまで待機/ブロックします。代わりに、あきらめて に進みたいdirect:cleanup
.
ファイルがある場合、shouldOnlyGetHereIfFileExists
Bean 内で処理されていることがわかりますが、コピーされていることはわかりません/home/myUser/myApp
。そのため、<otherwise>
要素が完全にスキップ/無視されているかのようです!
何か案は?前もって感謝します!