Hi, Have a look here
http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html and use separate thread in your processor to shutdown the Camel HTH Bilgin On 21 July 2013 15:29, bonnahu <bonn...@gmail.com> wrote: > Hey guys, > I need to shutdown the camelcontext in a Processor. Here is what I am doing: > > <bean id="downloadLogger" class="camelinaction.DownloadLogger"/> > <camelContext id="testingContext" > xmlns="http://camel.apache.org/schema/spring"> > > <route> > <from uri="file:src/data?noop=true"/> > <filter> > <xpath>/order[@test]</xpath> > <process ref="downloadLogger"/> > <to uri="jms:incomingOrders"/> > </filter> > </route> > </camelContext> > > Here is the DownloadLogger Processor: > > public class DownloadLogger implements Processor { > > //private Logger log = new Logger(DownloadLogger.class); > public void process(Exchange exchange) throws Exception { > System.out.println("We just downloaded: " > + exchange.getIn().getHeader("CamelFileName")); > System.out.println("before camel context stop"); > /exchange.getContext().getShutdownStrategy().setTimeout(5); > exchange.getContext().stop();/ > System.out.println("after camel context stop"); > } > } > > > When I run it, I got the following information. Can someone tell me why I > can't perform a graceful shutdown > here? > > > [ main] MainSupport INFO Apache > Camel 2.11.0 starting > [ main] SpringCamelContext INFO Apache > Camel 2.11.0 (CamelContext: testingContext) is starting > [ main] ManagementStrategyFactory INFO JMX > enabled. > [ main] DefaultTypeConverter INFO Loaded > 175 type converters > [ main] FileEndpoint INFO > Endpoint is configured with noop=true so forcing endpoint to be idempotent > as well > [ main] FileEndpoint INFO Using > default memory based idempotent repository with cache max size: 1000 > [ main] XPathBuilder INFO > Created default XPathFactory > com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@31e4c806 > [ main] SpringCamelContext INFO Route: > route1 started and consuming from: Endpoint[file://src/data?noop=true] > [ main] ultManagementLifecycleStrategy INFO Load > performance statistics enabled. > [ main] SpringCamelContext INFO Total > 1 routes, of which 1 is started. > [ main] SpringCamelContext INFO Apache > Camel 2.11.0 (CamelContext: testingContext) started in 0.431 seconds > [t) thread #0 - file://src/data] rFileExclusiveReadLockStrategy WARN > Deleting orphaned lock file: src\data\message1.xml.camelLock > We just downloaded: message1.xml > before camel context stop > [t) thread #0 - file://src/data] SpringCamelContext INFO Apache > Camel 2.11.0 (CamelContext: testingContext) is shutting down > *[t) thread #0 - file://src/data] DefaultShutdownStrategy INFO > Starting to graceful shutdown 1 routes (timeout 5 seconds) > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO > Waiting as there are still 2 inflight and pending exchanges to complete, > timeout in 5 seconds. > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO > Waiting as there are still 2 inflight and pending exchanges to complete, > timeout in 4 seconds. > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO > Waiting as there are still 2 inflight and pending exchanges to complete, > timeout in 3 seconds. > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO > Waiting as there are still 2 inflight and pending exchanges to complete, > timeout in 2 seconds. > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO > Waiting as there are still 2 inflight and pending exchanges to complete, > timeout in 1 seconds. > [t) thread #0 - file://src/data] DefaultShutdownStrategy WARN > Timeout occurred. Now forcing the routes to be shutdown now. > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy WARN > Interrupted while waiting during graceful shutdown, will force shutdown > now.* > [text) thread #2 - ShutdownTask] DefaultShutdownStrategy INFO Route: > route1 shutdown complete, was consuming from: > Endpoint[file://src/data?noop=true] > [t) thread #0 - file://src/data] DefaultShutdownStrategy INFO > Graceful shutdown of 1 routes completed in 5 seconds > [t) thread #0 - file://src/data] DefaultInflightRepository WARN > Shutting down while there are still 1 in flight exchanges. > [t) thread #0 - file://src/data] SpringCamelContext INFO Uptime > 6.521 seconds > [t) thread #0 - file://src/data] SpringCamelContext INFO Apache > Camel 2.11.0 (CamelContext: testingContext) is shutdown in 5.016 seconds > after camel context stop > [t) thread #0 - file://src/data] GenericFileOnCompletion WARN > Rollback file strategy: > org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@2d57f820 > for file: GenericFile[message1.xml] > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Why-cannot-do-a-graceful-shutdown-tp5735962.html > Sent from the Camel - Users mailing list archive at Nabble.com.