Apache Camel With Spring boot

Posted By : Shubhankar Ajmani | 29-Jun-2020


Apache Camel middleware provides you a messaging technology which makes use of routing and mediation rules. Two endpoints are required for apache camel PRODUCER & CONSUMER. From endpoint here refer 2 different URLs. Domain-specific language(DSL’S) is required for routing.



1) route.from

2) route.to


To use it with SPRING BOOT we make use of CAMEL CONTEXT


  public class NewOrderRoute extends RouteBuilder {


 CamelContext context;


 public void configure() throws Exception {


 log.info("streamCaching {}", context.isStreamCaching());



                .process(new EZRHeaderDetailsProcess())

                .log("Header ${body}").setHeader(Exchange.HTTP_METHOD, constant("POST"))

                .setHeader(Exchange.CONTENT_TYPE, constant("application/x-www-form-urlencoded"))


                .log("Received body ${body}").unmarshal(ezrJsonFormat)

                .process(new OMSNewOrderProcess()).marshal(omsJsonFormat)





Here from(String uri) is used to initiate the messaging process for building ROUTE


For example

-from("scheduler://getEZRNewOrders?initialDelay=600&delay=600000") in above code


process(Processor processor) is used to define the process for route defination .


   public class EZRReturnOrderHeaderProcess implements Processor {

 private DateTimeFormatter format1 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");

 private DateTimeFormatter format2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");


 public void process(Exchange exchange) throws Exception {



    private Object generateReturnOrderHeader() {

        String timeStamp = LocalDateTime.now().format(format1);

 StringBuilder inputValues = new StringBuilder();

 inputValues.append("AppId=" + EZRConfig.APP_ID);

 inputValues.append("&Timestamp=" + timeStamp);

 inputValues.append("&Token=" + EZRConfig.TOKEN);

 String value = inputValues.toString();

 return "AppId=" + EZRConfig.APP_ID + "&Timestamp=" + timeStamp + "&Sign=" + SignUtil.generateSHA1(value) + "&AppSystem=" + EZRConfig.APP_SYSTEM+

                "&Args={\"ReturnTimeStart\": " + LocalDateTime.now().minusDays(5).format(format2) + ",\n" +

                "\"ReturnTimeEnd\": " + LocalDateTime.now().format(format2) + ",\n" +

                "\"PageIndex\": \"1\"}";





to() is use to define the consumer of the route definition.


JacksonDataFormat ezrJsonFormat = new JacksonDataFormat(EZRResultSetDto.class);


JacksonDataFormat omsJsonFormat = new JacksonDataFormat(OMSOrderDto.class);


Further the marshalling and unmarshalling of data is also required to convert data from one form to another like JSON to JAVA Object .


MARSHALLING/UNMARHSALLING – Converting from original data to byte form and vice versa.


Following dependency is required for apache camel in spring boot project .







You can make use of folliwng alternative  messaging technology-


  • WSO2 Enterprise Service Bus.
  • IBM App Connect.
  • Software AG webMethods.

We are a ERP Development Company that enables enterprises to streamline operations and drive returns, using next-gen technologies, with our development services. Our services include developing applications for all your ERP needs from CRM, WFM, and HRM to eCommerce, accounting, and wealth management software. We use an extensive tech stack including Javascript, Springboot, JUnit to develop end to end customized software for your enterprise. Get in touch with our experts to know more about how you can implement these technologies into your business.



Please remove URL from text

Comment is required

Sending message..
Connect with us