You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2014/02/03 14:58:10 UTC

[jira] [Commented] (CAMEL-7156) SpringCamelContext should shut down cleanly

    [ https://issues.apache.org/jira/browse/CAMEL-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13889486#comment-13889486 ] 

Claus Ibsen commented on CAMEL-7156:
------------------------------------

Would require us to drop spring 3.1 support and spring 3.2 as minimum version. I guess that would be acceptable from Camel 2.13 onwards.

> SpringCamelContext should shut down cleanly
> -------------------------------------------
>
>                 Key: CAMEL-7156
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7156
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.12.2
>         Environment: spring application context
>            Reporter: John Mark
>             Fix For: Future
>
>
> The CamelContext does not shutdown properly when running inside a Spring ApplicationContext.  Upon shutdown I get a lot of the following errors:
> {noformat}
> org.apache.camel.RuntimeCamelException: org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'someBean': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
> 	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1196)
> 	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:51)
> 	at org.apache.camel.component.bean.RegistryBean.lookupBean(RegistryBean.java:136)
> 	at org.apache.camel.component.bean.RegistryBean.getBean(RegistryBean.java:62)
> 	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:83)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
> 	at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:85)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
> 	at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.DelayProcessorSupport.process(DelayProcessorSupport.java:105)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
> 	at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
> 	at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> 	at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:114)
> 	at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)
> 	at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
> 	at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
> 	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
> 	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
> 	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)
> 	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)
> 	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:636)
> Caused by: org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'someBean': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:209)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
> 	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
> 	at org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:66)
> 	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:49)
> 	... 78 more
> {noformat}
> I can use depends-on for every bean that my context uses, but I shouldn't have to do that.  It can also be hard to manage that type of pattern.
> I think SpringCamelContext should implement the SmartLifecycle interface from Spring (see http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/beans.html#beans-factory-lifecycle).
> {{int getPhase();}} should return a high value (probably Integer.MAX_VALUE) and {{void stop(Runnable callback);}} should only call {{callback.run()}} once the camel context has completed shutting down.  
> I think this would enable camel to shutdown cleanly in spring without users having to specify that every bean that is used depends-on the camel context.  The only issue I can see is the disconnect between camel's default shutdown time and spring's default shutdown timeout.  The camel context has a default shutdown timeout of 300 seconds (http://camel.apache.org/graceful-shutdown.html) while spring's per-phase timeout is 30 seconds (http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/beans.html#beans-factory-lifecycle).  It would be nice if those two were in sync.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)