June 17, 2019

Consuming files from folders with Apache Camel

Apache Camel is a an open-source integration framework written in Java that helps the user implement many of the design patterns defined in the book Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf. The book discusses 65 design patterns for asynchronous messaging systems and Camel implements many of the design patterns in the EIP book.
Aim of Camel is to make easier the integration of different applications which use several protocols and technologies.
In this article I make use of some fundamental Camel objects like Route Builder, Processor and File Component to poll a given directory and consume from a file endpoint. You can find further details here:



Apache Camel 2.17.3
JDK 1.8
Maven 3.2

SOURCE CODE (/giuseu/activemq)

git clone https://gitlab.com/giuseppeurso-eu/activemq

The source code covered in this post is located under the subfolder camel-polling-directory.


The endpoint URI builder. The File component provides access to file systems, allowing files to be processed by a Consumer.


The CamelContext initializer. This class make use of Thread.sleep to simulate a runtime system of 30 seconds. During the poll operation, the ConsumerRouteBuilder is used to monitor the state of the source directory and then start message exchanges.


The processor of files from the source directory.


Related posts

Leave a Reply

Your email address will not be published.