Simple “Hello World” application using Apache Camel

I’ve learned this API few months back, and the initial days with this API was a real struggle. Now I’ve better grip on this API, and thought of sharing my experience here so that anyone comes across same situations as mine can make use of this.

This article will cover preparing a simple “Hello World” application using Apache Camel. I’ve used logging messages from camel routes in this example.

Software/API Used:

  1. JDK 1.8
  2. Eclipse Luna
  3. Maven
  4. Camel 2.18.2
  5. Activemq 5.6.0

First add the required maven dependencies to your application.


Below is the code snippet for a standalone java application with Camel. This program will read message from activemq and print the message in console after 5 seconds delay.

package com.jyothis.camel.samples;

import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.LoggingLevel;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class CamelSampleApplication {
    public static void main( String[] args ) throws Exception {
    	CamelContext context = new DefaultCamelContext();
    try {
      context.addComponent("activemq", ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
      context.addRoutes(new RouteBuilder() {
        public void configure() throws Exception {
            .log(LoggingLevel.INFO, "Received message from queue:myQueue...")
            .log(LoggingLevel.INFO, "Message received is :")
      ProducerTemplate template = context.createProducerTemplate();
      template.sendBody("activemq:myQueue", "Hello World");
    } catch (Exception e) {
    } finally {


Leave a Reply

Your email address will not be published. Required fields are marked *