ST2CCO - Advanced Cloud Computing - Spring Integration
This application takes place for the final project of the course ST2CCO.
We have choose to read some files (actors.csv
and movies.csv
) then load them into Java objects and finally convert them into JSON string and save it into jsons files.
This application demonstrate our knowledge about the Spring pattern.
You can import the project using IntelliJ IDEA software (File
-> Open
and select the project folder).
Using IntelliJ IDEA, you can run the project using the Run
menu (or press Alt
+Maj
+F10
)
-
inbound-channel-adapter
- used to read files for a specific directory (heredataIn
) -
splitter
- used to parse the message string into csv object -
header-value-router
- used to route message based on his source file name (eg.actors.csv
ormovies.csv
) -
transformer
- used to convert the message payload (a csv object) into a JAVA (Actor
orMovie
) object -
object-to-json-transformer
- used to parse the JAVA (Actor
orMovie
) object into a JSON string -
outbound-channel-adapter
used to store the message payload into a file -
filename-generator
- helper foroutbound-channel-adapter
pattern to determine the output filename based on the message header source filename
This Spring application will load the Schema-based configuration: movieApplication.xml
.
This file will define the overall "pipeline" to use for the application messages flow.
We have iterate from a single actor
flow to two flows (actors
and movies
) and finally we have wrapped all of that inside a single Spring Application.
Below is explained the iterative work for each flow.
We have first develop a flow for the actors.csv
file, that include a custom transformer (used to create an Actor object).
After developing the actors flow, we have copied it for the movie input files. And we have made some ajustment :
- We have created a specific transformer method to create a Movie Java Object
We have previously see that we use 2 flows that can be run side-by-side. Whit that in mind we can implement a router for each flow. As we know, Actors and Movies flow are almost identical :
- The
inbound-channel-adapter
must be adapted to parse bothactors.csv
andmovies.csv
, we have done that by using a wildcard on the source file name parameter:*.csv
- A specific transformer must be used for each message type: if the message is from the
actors.csv
we must use theActors Transformer
or if the message if from themovies.csv
file we must use theMovies Transformer
. After searching the Spring documentation, we have fount that a router is able to do this job. As we know the source filename is save in each message header, we have implemented aheader-value-router
to route each message to the corresponding Transformer.
In order to parse the file *.csv
into a Java CSV object we have used the opencsv
helper.
In order to minimize the application code, we have used the lombok
.