Hi all,
I have a problem with the lazy initialisation of a JMS component:

I have the following Spring configuration (JMS connection factory will be
looked up via JNDI):

        <bean class="org.apache.camel.component.jms.JmsComponent" id="queue"> 
            <property name="connectionFactory" ref="jmsQueueConnectionFactory" 
/>    
        </bean>
         
        <bean class="org.springframework.jndi.JndiObjectFactoryBean"
id="jmsQueueConnectionFactory" >
             <property name="jndiTemplate" ref="jndiTemplate" />             
             <property name="jndiName" value="${connectionFactoryName}" />
        </bean>
        ...

This works fine so far. The only problem is that this will try to setup the
JMS connection right at startup. What I want is a solution that starts the
whole JMS thing at the moment a camel endpoint is created that needs it but
not before this moment (I need this for integration tests where the
JMS-endpoints are replaced by file endpoints because the test systems do not
nessecarily have access to the JMS broker)

So I configured all the beans to "lazy-init=true" and told the
JNDIObjectFatcory bean to be looked up NOT at startup:

        <bean class="org.springframework.jndi.JndiObjectFactoryBean"
id="jmsQueueConnectionFactory" lazy-init="true">
             <property name="jndiTemplate" ref="jndiTemplate" />
             <property name="lookupOnStartup" value="false" />
             <property name="jndiName" value="${connectionFactoryName}" />
        </bean>

This works, but as soon as I setup a Camel route using my "queue" bean, I
get errors because the camel JMS endpoint cannot find it, so it does not set
up the JMS connection "on demand", as I would have expected.

Any ideas how to do this right?

Thanks for any ideas.

Best regards,
Joerg



--
View this message in context: 
http://camel.465427.n5.nabble.com/Lazy-init-for-JMS-Component-tp5769586.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to