This is a SpringBoot project to do a very simple practice of the enterprise integration patterns using the spring framework.
The system does the following:
-
Reads csv files from a folder using an inbound channel adapter and places them into a channel called "csvFilesChannel"
-
A transformer reads the file from the channel and transorms it into a byte array and sends this byte array to another channel called "routingChannel".
-
The "routingChannel" sends the files to a recipipent-list-router that multiplexes the message in two separate channels, one for processing called "csvProcessingChannel" and another for saving a backup of the processed file called "saveProcessedFileChannel".
-
"routingChannel" flow:
- A service activator calls a service to process the file from the processing channel and store its contents in a relational database.
- After processing the file the message is sent to an outbound channel adapter that ends the flow.
-
"saveProcessedFileChannel" flow:
- An outbound channel adapter ends the circuit on the backup side saving the file to the processed folder.
-
Here is the diagram generated by Eclipse STS.
git clone https://github.com/Alfredux79/csv-processor.git
cd csv-processor
mvn spring-boot:run
- When the program starts it creates the filesystem folder, with the input and processed folders inside and an empty H2 database that can be checked at the url http://localhost:8080/h2
- There is a sample csv file at the resources folder.
- Copy the file to the input folder and 2 things should happen:
- The file has been moved from the input folder to the processed folder
- A record has been written to the H2 database with the contents of the file