Spring 3.0 lazy-init not honoured for DefaultMessageListenerContainer?

后端 未结 2 1350
自闭症患者
自闭症患者 2021-01-21 01:09

I\'ve setup a spring config for JMS. Things work fine, except I can\'t seem to get it to lazy load (notice the default-lazy-init true in the code below). If I comment out the jm

相关标签:
2条回答
  • OK, this is pretty obscure, but DefaultMessageListenerContainer implements the Lifecycle interface, and beans that implement this are tied into the context's own lifecycle - when the context starts up, Lifecycle-implementing beans are initialised and started. This means that your lazy-init config is essentially ignored.

    0 讨论(0)
  • 2021-01-21 02:09

    The solution is to use autoStartup to false. See the code below.

    <bean id="listenerContainer"
        class="org.springframework.jms.listener.DefaultMessageListenerContainer">
         ........
        <property name="autoStartup" value="false"/>
    </bean>
    

    ~Shyam

    0 讨论(0)
提交回复
热议问题