Announcement Announcement Module
Collapse
No announcement yet.
Introducing a delay into bean initialization? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Introducing a delay into bean initialization?

    Hi,

    I have two webapps. One is an instance of ActiveMQ, the other a webapp with a SimpleMessageListenerContainer. Both webapps load in the same instance of Tomcat but the webapp with the listener loads first. The connectionFactory gives errors because ActiveMQ hasn't finished loading. Ideas?

    <bean id="connectionFactory" class="org.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL">
    <value>tcp://localhost:61616</value>
    </property>
    </bean>

    <bean id="jmsContainer" class="org.springframework.jms.listener.SimpleMess ageListenerContainer">
    <property name="concurrentConsumers" value="40" />
    <property name="destination" ref="fileMonitorDestination" />
    <property name="messageListener" ref="fileMonitorMessageConsumer" />
    <property name="connectionFactory" ref="connectionFactory" />
    </bean>

  • #2
    Webapps are supposed to be independent so there are no ways specified by the spec how to do synchronization. Try looking at your application server options or even better add this synchronization programatically - that is for example, create a bean that will try to connect to ActiveMQ and can retry for X times, after each failure waiting Y seconds (similar to what most pooling implementations do).

    Comment


    • #3
      JBoss lets you define dependencies between components, i'm pretty sure for exactly this reason.

      JBoss has Tomcat 5.5.16 (?) embedded.

      Other than that, can you make the connection factory lazy-init and then create a timer task to initialise it?

      Comment


      • #4
        Thanks, I think I will try the "lazy-init" approach first..

        Damon.

        Comment

        Working...
        X