Announcement Announcement Module
No announcement yet.
Question on MessageBus autoStartup Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on MessageBus autoStartup

    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"/>

    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:

    In AbstractApplicationContext:
    // Implementation of Lifecycle interface

    public void start() {
    Map lifecycleBeans = getLifecycleBeans();
    for (Iterator it = new LinkedHashSet(lifecycleBeans.keySet()).iterator(); it.hasNext() {
    String beanName = (String);
    doStart(lifecycleBeans, beanName);
    publishEvent(new ContextStartedEvent(this));

    Any suggestion on this problem?


  • #2
    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