Camel Spring Boot

File Watch

Receive an event when a file or directory is created, modified or deleted in a directory of the file system.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-file-watch-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 8 options, which are listed below.

Name Description Default Type

camel.component.file-watch.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.file-watch.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.file-watch.concurrent-consumers

The number of threads that take the events from the queue and route them. Increase it when the route is slower than the events arrive. With more than one thread, the events can be routed in another order than they occurred.

1

Integer

camel.component.file-watch.enabled

Whether to enable auto configuration of the file-watch component. This is enabled by default.

Boolean

camel.component.file-watch.file-hasher

The io.methvin.watcher.hashing.FileHasher that hashes each file to drop duplicate events, such as a MODIFY event of a file whose hash did not change. The default #murmur3FFileHasher hashes the content, and so reads every file in the directory tree in full when the consumer starts; #lastModifiedTimeFileHasher uses the last modified time instead, which suits large files. Not used when useFileHashing is false. The option is a io.methvin.watcher.hashing.FileHasher type.

FileHasher

camel.component.file-watch.poll-threads

The number of threads that read the events from the watch service of the directory and put them in the queue. Increase it when the log warns that an OVERFLOW occurred, which means that the file system dropped events. All the threads read the same watch service, and each one registers the watched directories again when the consumer starts (and hashes their files again when useFileHashing is enabled), so on a large tree a higher value makes the start slower. More threads can only help when the events come from several directories at the same time, as the events of one directory are read by one thread at a time.

1

Integer

camel.component.file-watch.queue-size

The maximum number of events in the queue between the pollThreads threads and the concurrentConsumers threads. When the queue is full, new events are dropped and a warning is logged once. A value of 0 or less means no limit.

2147483647

Integer

camel.component.file-watch.use-file-hashing

Whether to hash the files with the fileHasher to drop duplicate events, as some platforms and JDKs report a change more than once. If false, no file is hashed, and the route can receive the same event more than once.

true

Boolean