100.19. ファイルへの書き込み
Camel は当然、ファイル(つまりファイルの生成)も記述できます。以下の例では、ディレクトリーに書き込まれる前に、処理する SEDA キューに関するレポートの一部を受信します。
100.19.1. Exchange.FILE_NAME
を使用してサブディレクトリーに書き込みます。
単一ルートを使用すると、ファイルを任意の数のサブディレクトリーに書き込むことができます。以下のようなルートが設定されている場合:
<route> <from uri="bean:myBean"/> <to uri="file:/rootDirectory"/> </route>
<route>
<from uri="bean:myBean"/>
<to uri="file:/rootDirectory"/>
</route>
myBean
で、ヘッダー Exchange.FILE_NAME
を以下のような値に設定できます。
Exchange.FILE_NAME = hello.txt => /rootDirectory/hello.txt Exchange.FILE_NAME = foo/bye.txt => /rootDirectory/foo/bye.txt
Exchange.FILE_NAME = hello.txt => /rootDirectory/hello.txt
Exchange.FILE_NAME = foo/bye.txt => /rootDirectory/foo/bye.txt
これにより、複数の宛先にファイルを書き込む単一のルートを作成できます。