Why does my file consumer not pick up the file, and how do I let the file consumer use the Camel error handler?
There could be several reasons why the File consumer is not picking up files. For example it may not run at all, or it cannot acquire a read lock on the file.
Check the logs for any exceptions or other informative messages. You can turn on DEBUG logging at
org.apache.camel.component.file to see more detail.
How to use Camel's routing error handlers with the file consumer
Well, this is really a "chicken or the egg" question. The Camel error handler (e.g., in the routes) only applies when a message is being routed by the routing engine.
Before this happens, a consumer must successfully receive a message, create a Camel Exchange, populate the Exchange with message details (e.g., body and headers), and then pass the Exchange to the routing engine. Only at this point can the routing error handler deal with exceptions occurring. Before this point, any error handling is really Component-specific.
If the component consumer extends the
DefaultConsumer from Camel, then it offers an
org.apache.camel.spi.ExceptionHandler hook for end users to plug-in a custom strategy. The default implementation from Camel is
LoggingExceptionHandler that will log the exception at
WARN level, and then ignore the exception.
See the File page in the bottom for an example how to use a custom
ExceptionHandler that sends a new message to the Camel routing engine, which then allows the routing engine to trigger its own error handling to deal with the exception.