Friday 17 October 2014

A Fun Camel Ride With Apache Camel Part One The Problem Statement

I have been a Camel Rider for a while now. It is one of the best EIP frameworks out there. A lot of ESB products rely on this framework as their backbone for getting systems integrated. Any business that has integration needs can investigate this framework to achieve integration nirvana. As a CIO of a medium sized business and it has served us extremely well providing robust, scalable and secure integration between our company and several large blue chip organisations.

The Camel community is absolutely great and have helped me immensely while getting to grips with the basics and thus I would like to help out a little by writing a series of tutorials to take you from a basic route to some of the more advanced techniques you can use in Camel. Just to be clear this will not cover the concepts of Camel but rather take you through a working design.

So you will need some experience in getting Camel before attempting this tutorial.The main aim is to get a route up and running quickly and then apply some of the more advanced scaling techniques I have uncovered. This tutorial will also assume you have working knowledge of Eclipse, Java, MySQL and Maven. If you are a brand new beginner and you are serious about learning this awesome framework do purchase the book Camel In Action. It is a tremendously good read and a very good way to get your feet wet.

To make this series of tutorials a little more relevant I decided to base it around a real life problem I have. Over the years I have purchased a lot of music(MP3) and converted my CD collection(400+ Albums) to various formats(FLAC, WMA etc), unfortunately I did not keep my library in a good shape.

It has become a little frustrating to find that song in my library so I am going to use Camel to sort out my problem. Essentially I want to point Camel at my library of music and then have the framework catalogue my collection properly by placing the music files into an appropriate folder after having determined the album name and artist name I would also like to create a database of information around my collection.

So lets clearly identify my requirements:
  1. Read a source folder and all sub-folders
  2. For each file found send that to a tag analyser
  3. In the tag analyser try and read the tags of the file:
    1. If we can read the meta-data tags of every file to try and determine the following information:
      • Artist Name
      • Album Name
      • Genre Name
    2. If we could read any meta data tags for a file send the file to a process that will insert this data into music database. After inserting the data then send the file to a catalogue process that will create the appropriate directories to store the file in
    3. If we cannot read any meta-data tags mark this file as an exception and send it to an exception process.
  4. In the database process insert the meta data into various tables such as album, genre, artist, song name etc(This will be defined with the database).
  5. In the file catalogue process create the appropriate directory if need to place the file in. The rules for creating directories will be as follows:
    • If the album name is known then create a folder in the destination with the album name
    • If the album name is not known but we have the name of the artist then create folder for the artist and place the file under the artist name
    • If both the album and artist name is not known then use the genre to create a folder and place the file in the genre folder
    • If none of the above conditions are met then send it to a folder called NoTagData
For the more visual of the readers I have provided the following flow chart:

High Level View Of Logic Flow In Camel Route

Hopefully the above instructions are clear enough to give you a good idea of what I want to achieve.The next part of this tutorial will be about the required pieces such as the database, tag library and other software you will need to get this route done.

No comments:

Post a Comment