This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Question on MessageBus autoStartup

Dec 11th, 2008, 09:35 PM

Hi,
I am using Spring Integration M4 and I want to start the MessageBus manually, but I found that even I set the following:
<bean id="internal.MessageBus" class="org.springframework.integration.bus.Message Bus" ">
<property name="autoStartup" value="false"/>
</bean>

The MessageBus is still started by the ApplicationContext, I trace the spring framework source, seems the problem is due to Spring will trigger the start() for all beans implement LifeCycle interface:

The cascading of Lifecycle method invocations within an ApplicationContext is expected behavior. However, the ApplicationContext itself is not started automatically. In other words, only if you want to start all Lifecycle beans within a context, then call start() on the ApplicationContext instance itself. Otherwise, individual Lifecycle beans may be managed independently.

As far as Spring Integration is concerned, this is actually one of the reasons that there is no longer a centralized MessageBus component. In the 1.0 final release, the ApplicationContext *is* the "Message Bus".

In summary:

1) if you are using M4, then autoStartup=false should prevent the starting of the bus unless you are explicitly invoking start() on the context itself somewhere.

2) if possible, you should upgrade to the 1.0 final release of Spring Integration