Reputation: 247
I would like to read directory with specific file path and get the file contents with apache camel and spring boot. I have router and processor class in Java. There are not many resources on the Internet, but only on the official website of apache camel. Thank you in advance.
Upvotes: 1
Views: 3769
Reputation: 4106
One option is to use the Apache Camel File component to consume files. One thing to keep in mind however is that if you're deploying in a clustered environment, extra precautions need to be taken to avoid competing consumer issue. From the documentation:
Warning: most of the read lock strategies are not suitable for use in clustered mode. That is, you cannot have multiple consumers attempting to read the same file in the same directory. In this case, the read locks will not function reliably. The idempotent read lock supports clustered reliably if you use a cluster aware idempotent repository implementation such as from Hazelcast Component or Infinispan.
Because of this and other complexities, I typically avoid using the Camel file component for consuming files and just use java.nio.file.Files API in a bean/processor as it is more straightforward and provides easier mechanisms for dealing with this and other limitations.
Upvotes: 1