Results 1 to 4 of 4

Thread: Introducing a delay into bean initialization?

  1. #1
    Join Date
    Jul 2005
    Posts
    11

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    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?

  4. #4
    Join Date
    Jul 2005
    Posts
    11

    Default

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

    Damon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •