RSS

Monthly Archives: October 2015

Apache-Camel with Java (Integration)

Apache-Camel with Java (Integration)

Apache camel is very useful routing implementation. If you involve with some integration then you will realize how it is solving your problems. When technology evolves Integration will come to the picture as follows.

A company has a software, which runs in old technology. The company wants to go for another tool, which is going to work on latest platforms and technology. But still the company need to get integrated with the old system because new tool depends on the company data, which is in old system. In this case we need to come up with good solution that can be bridge to the communication. In the industry we used Message Queues to make realtime communication so if it is realtime we can use the message queue in between the two systems.

Above sample is really simple scenario but think about if you have number of systems in downstream to communicate, then you will need proper routing mechanism otherwise you will end up with multiple endpoints, which is doing the same thing (duplicate work). Apache Camel is open source tool for routing data with JAVA application.

Apache Camel

I have created simple adapter with apache camel routes. It explains how to use camel routes in implementation level. This is a maven project produce the war file, which you can deploy on apache tomcat and subscribe to the queue. ( I hope you have understanding of use Spring Boot and Spring Profile) This sample doesn’t contain JMS client to publish messages so I’m going to use the ActiveMQ console.

You can clone the whole project in following location. https://github.com/malalanayake/camel-sample

In code level you need to create the camel route and camel message processor as you wish. See the following rout configuration and sample message processor implementation.

Follow the instruction to deploy and run the adapter.

Start Apache ActiveMQ and create the queue as “sample_queue” then change the application-dev.properties in resource folder. I used spring profile for switch the context so you need to update the default profile as follows in application.properties

Now build the WAR file and deploy the WAR on Apache Tomcat. Then you will see the WAR adapter is going to subscribe to the sample_queue

activemq

Now go to operation and do “Send To“. Now your adapter is going to consume the given message. See the logs in tomcat console.

send

 

 

after_sent

 

console

 

after_consume

The routing mechanism and routing patterns might vary with the problem domain. However the implementation perspective is similar. For example subscribe to message queue and then route the message to endpoints. I hope you got some idea how to use the camel routes.

Enjoy the integration.

 
3 Comments

Posted by on October 11, 2015 in integration, java, spring

 

Tags: , , , ,

 
%d bloggers like this: