Let me add that I see around 5-6 inflight exchanges in the jconsole
(via JMX) before I hit stop(). So there are exchanges, but the log
statements say there are none..

Thanks again,

Ilya

On Thu, Apr 15, 2010 at 8:37 AM, Ilya S <devmailboxl...@gmail.com> wrote:
> Here is my full route:
>
>
>        from("jetty:http://0.0.0.0:8686/hello";)
>        .process(new Processor() {
>                        public void process(Exchange exchange) throws 
> Exception {
>
>                                String body = 
> exchange.getIn().getBody(String.class);
>                                Integer ii = Integer.parseInt(body);
>
>                                System.out.println("About to process: " + ii);
>                                System.out.println("Sending to numbers2 queue 
> to wait...");
>
>                                exchange.getOut().setBody(ii);
>                        }
>                })
>                .to("jms:queue:numbers2?requestTimeout=50000")
>                .process(new Processor() {
>                        public void process(Exchange exchange) throws 
> Exception {
>                                Integer ii = 
> exchange.getIn().getBody(Integer.class);
>                                System.out.println("Back to processing of: " + 
> ii);
>                                exchange.getOut().setBody(ii);
>                        }
>                })
>        .to("multiplier");
>
>
> The other queue (jms:queue:numbers2) is a part of another route (in
> another Camel context):
>
>        from("jms:queue:numbers2")
>                .process(new Processor() {
>                        public void process(Exchange exchange) throws 
> Exception {
>                                int sleepTime = (int)(Math.random()*25000);
>                                System.out.println("Received from 
> numbers2....Going to sleep now
> for " + sleepTime/1000 + " seconds");
>                                Thread.sleep(sleepTime);
>
>                                Message in = exchange.getIn();
>                                exchange.getOut().setBody(in.getBody());
>                        }
>                });
>
>
>
> I initiate the shutdown on the first Camel Context via JMX. If I
> remove the http component, and only use JMS components, the shutdown
> works just fine. With all the INFO messages about waiting for inflight
> exchanges to finish printed.
> As soon as I add Jetty, and initiate a stop() call, I'm getting the
> following output in the logs:
>
> Back to processing of: 1
> About to process: 2
> Sending to numbers2 queue to wait...
> Back to processing of: 2
> About to process: 3
> Sending to numbers2 queue to wait...
> Back to processing of: 2
> About to process: 3
> Sending to numbers2 queue to wait...
> [CP Connection(4)-10.58.123.154] DefaultCamelContext            INFO
> Apache Camel 2.2.0 (CamelContext:camel) is stopping
> [CP Connection(4)-10.58.123.154] DefaultShutdownStrategy        INFO
> Starting to graceful shutdown routes (timeout 300 seconds)
> [        6718...@qtp-21758581-2] DefaultErrorHandler            ERROR
> Failed delivery for exchangeId: b5e983a8-4777-4db5-997c-3e4daf17c13e.
> On delivery attempt: 0 caught:
> org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 50000 millis. Exchange[Message: 1]
> [       16889...@qtp-21758581-5] DefaultErrorHandler            ERROR
> Failed delivery for exchangeId: b6653535-c32c-49c6-af6f-89fc0d58bbcf.
> Exhausted after delivery attempt: 1 caught:
> org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 50000 millis. Exchange[Message: 2]
> org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 50000 millis. Exchange[Message: 2]
>        at 
> org.apache.camel.component.jms.JmsProducer.processInOut(JmsProducer.java:265)
>        at 
> org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:147)
>        at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>        at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>        at 
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at 
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>        at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at 
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at 
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
>        at 
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at 
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>        at 
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)
>        at 
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:53)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>        at 
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>        at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>        at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>        at 
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
>        at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>        at org.mortbay.jetty.Server.handle(Server.java:326)
>        at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>        at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>        at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
>        at 
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> [       19538...@qtp-21758581-4] DefaultErrorHandler            ERROR
> Failed delivery for exchangeId: c5090377-e834-4b79-9b47-2512080c0632.
> Exhausted after delivery attempt: 1 caught:
> org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 50000 millis. Exchange[Message: 3]
> org.apache.camel.ExchangeTimedOutException: The OUT message was not
> received within: 50000 millis. Exchange[Message: 3]
>        at 
> org.apache.camel.component.jms.JmsProducer.processInOut(JmsProducer.java:265)
>        at 
> org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:147)
>        at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>        at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>        at 
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at 
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>        at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at 
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at 
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)
>        at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
>        at 
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at 
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>        at 
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)
>        at 
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at 
> org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:53)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>        at 
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>        at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>        at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>        at 
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
>        at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>        at org.mortbay.jetty.Server.handle(Server.java:326)
>        at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>        at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>        at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
>        at 
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> [ Camel thread 11: ShutdownTask] DefaultShutdownStrategy        INFO
> Route: route1 shutdown complete.
> [CP Connection(4)-10.58.123.154] DefaultShutdownStrategy        INFO
> Graceful shutdown of routes completed in 0 seconds
> [CP Connection(4)-10.58.123.154] DefaultInflightRepository      INFO
> Shutting down with no inflight exchanges.
> [CP Connection(4)-10.58.123.154] DefaultCamelContext            INFO
> Apache Camel 2.2.0 (CamelContext:camel) stopped
>
>
> I tried to fix this by extending JettyHttpComponent and overriding
> createServer method as follows:
>
>       �...@override
>        protected Server createServer() throws Exception {
>         Server server = super.createServer();
>         server.setGracefulShutdown(50000);
>         server.setStopAtShutdown(true);
>
>         return server;
>        }
>
> This seemed to work, but I'm not sure if that's the right approach.
>
>
> Any help is greatly appreciated.
>
> Thanks,
> Ilya.
>
>
>
> On Thu, Apr 15, 2010 at 2:17 AM, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> Hi
>>
>> All the unit tests run with graceful shutdown by default, and all unit
>> tests with camel-jetty shut down with no issues.
>>
>> The in flight repository do keep track of all in flights. I can only
>> think of if you use the aggregator or some custom code which
>> can cause the exchange to be completed in Camels point of view.
>>
>> Can you post your entire route?
>>
>> And as always report which version of Camel you are using? And try
>> with the latest stable and even with 2.3-SNAPSHOT.
>>
>>
>> On Wed, Apr 14, 2010 at 7:41 PM, Ilya S <devmailboxl...@gmail.com> wrote:
>>> Hi All,
>>>
>>> Fist of all, thank you for this great product!
>>> Every new release brings excellent new features just in time.
>>>
>>> I'm currently investigating Graceful Shutdown feature, and I'm am
>>> wondering if graceful shutdown is supported for Camel-Jetty component?
>>> I was able to successfully shut down JMS component. However,
>>> JettyHttpCoponent seems to have issues when shutting down.
>>>
>>> In my simple test (adopted from camel-example-spring-jms:ServerRoute
>>> example) I have a simple route that looks like this:
>>>
>>> from("jetty:http://0.0.0.0:8686/hello";)
>>> ..
>>> .. do work
>>> ...
>>> .to("jms:queue:numbers2?requestTimeout=50000")
>>> .to("multiplier");
>>>
>>>
>>> My producers simply send numbers to http endpoint..
>>>
>>>
>>> When I shutdown this context gracefully I'm getting all sort of
>>> exceptions from Jetty, and the context does not seem to wait until
>>> inflight exchanges have finished.
>>> I'm using the defaults everywhere (e.g. default shutdown strategy).
>>>
>>> Is shutdown supported for Jetty, and if so how should one configure
>>> jetty to initiate proper shutdown?
>>>
>>> Thank you,
>>>
>>> Ilya.
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>

Reply via email to