camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From contactreji <>
Subject Camel App as a batch
Date Fri, 18 Mar 2016 08:33:46 GMT
Hey guys

I am need to have an application which terminates once the exchanges are
completed. I used a main class like follows to boot my application which did
the job for me.

import org.apache.camel.spring.SpringCamelContext;
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.ApplicationContext;

public class AppBoot {
    public static void main(String[] args) throws Exception
        ApplicationContext ac = new
        SpringCamelContext camelContext = (SpringCamelContext)
        //Loading time for all camel routes
        //Stop camel context only once Inflight exchanges are 0. i.e no
camel routes are processing any data
            System.out.println("Application Running with inflight exchanges
= "+camelContext.getInflightRepository().size());
        System.out.println("Application ran for "+camelContext.getUptime());

I decided to monitor the number of inflight exchanges as a criteria for
terminating job.

But this way of doing things failed when exchanges were sent to camel
aggregators. My aggregator has a timeout value of 30 seconds and if new
exchanges don't arrive in aggregator, the condition
camelContext.getInflightRepository().size()>0 evaluates to false and routes
start graceful shutdown..

Is there a way I can keep a check on my aggregator bucket as well? Or
probably a better method of achieving this feature?


Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse
ESB | Mule ESB )
LinkedIn -
Twitter - reji_mathews
View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message