23.21. 写入文件
Camel 还可以编写文件,例如生成文件。在下面的示例中,我们收到一些有关在将进程写入目录之前处理的 SEDA 队列的报告。
23.21.1. 使用 Exchange.FILE_NAME写入子目录 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
使用单一路由时,可以将文件写入任意数量的子目录。如果您有路由设置,例如:
<route> <from uri="bean:myBean"/> <to uri="file:/rootDirectory"/> </route>
<route>
<from uri="bean:myBean"/>
<to uri="file:/rootDirectory"/>
</route>
您可以将标头 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
这样,您可以有一个路由来将文件写入多个目的地。