You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by saw <tr...@hotmail.com> on 2011/01/17 22:33:48 UTC

Route stops consuming from jms queue after several stop/resume

We have a need for one of our routes to be active only within a certain time
window. 
To accomplish we are using quartz to fire events at the window boundaries
and then starting or stopping the route programmatically using
exchange.getContext().start/stopRoute. (for the purposes of this we have
also tried suspend/resume but the problem persists).

The route consumes messages from a jms queue. The problem is that after a
certain number of start/stops the route stops consuming messages from the
queue.
We have noticed that when this happens the number of consumers on the jms
queue rises from 1 to 2.
It is as if the route starts up twice after a certain number of start/stops,
but one of those instances is not really active and it doesn't consume any
messages.

The problem is that this happens very randomly and we can't tell why. I have
managed to reproduce the problem consistently by simply having the route
start/stop very frequently (every minute or so). It is random, but
eventually it does happen.

We are using camel 2.5 inside spring 3.0.5, and activeMQ 5.4.2 

This is our config:

    ....
    <amq:connectionFactory id="amqConnectionFactory"
brokerURL="${jmsBroker}" />
    
    <bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
        <constructor-arg ref="amqConnectionFactory" />
        <property name="sessionCacheSize" value="50" />
    </bean>

    <!-- JmsTemplate Definition. This is used to access the jms queues
directly from spring -->
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
       <constructor-arg ref="connectionFactory"/>
    </bean>
    
    <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="transacted" value="false"/>
    </bean>

    <bean id="jms"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="configuration" ref="jmsConfig"/>
    </bean>

    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <!-- This route runs only at specific time windows and consumes from
jms -->
        <route id="messageSender" autoStartup="false" >
            <from uri="jms:messageQueue" />
            <process ref="mesageGenerator" />
             ....

-- 
View this message in context: http://camel.465427.n5.nabble.com/Route-stops-consuming-from-jms-queue-after-several-stop-resume-tp3345172p3345172.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route stops consuming from jms queue after several stop/resume

Posted by Claus Ibsen <cl...@gmail.com>.
Try without that Spring caching connection factory.

The AMQComponent is optimized and has pooling out of the box.


On Mon, Jan 17, 2011 at 10:33 PM, saw <tr...@hotmail.com> wrote:
>
> We have a need for one of our routes to be active only within a certain time
> window.
> To accomplish we are using quartz to fire events at the window boundaries
> and then starting or stopping the route programmatically using
> exchange.getContext().start/stopRoute. (for the purposes of this we have
> also tried suspend/resume but the problem persists).
>
> The route consumes messages from a jms queue. The problem is that after a
> certain number of start/stops the route stops consuming messages from the
> queue.
> We have noticed that when this happens the number of consumers on the jms
> queue rises from 1 to 2.
> It is as if the route starts up twice after a certain number of start/stops,
> but one of those instances is not really active and it doesn't consume any
> messages.
>
> The problem is that this happens very randomly and we can't tell why. I have
> managed to reproduce the problem consistently by simply having the route
> start/stop very frequently (every minute or so). It is random, but
> eventually it does happen.
>
> We are using camel 2.5 inside spring 3.0.5, and activeMQ 5.4.2
>
> This is our config:
>
>    ....
>    <amq:connectionFactory id="amqConnectionFactory"
> brokerURL="${jmsBroker}" />
>
>    <bean id="connectionFactory"
> class="org.springframework.jms.connection.CachingConnectionFactory">
>        <constructor-arg ref="amqConnectionFactory" />
>        <property name="sessionCacheSize" value="50" />
>    </bean>
>
>    <!-- JmsTemplate Definition. This is used to access the jms queues
> directly from spring -->
>    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>       <constructor-arg ref="connectionFactory"/>
>    </bean>
>
>    <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>        <property name="connectionFactory" ref="connectionFactory"/>
>        <property name="transacted" value="false"/>
>    </bean>
>
>    <bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>        <property name="configuration" ref="jmsConfig"/>
>    </bean>
>
>    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>        <!-- This route runs only at specific time windows and consumes from
> jms -->
>        <route id="messageSender" autoStartup="false" >
>            <from uri="jms:messageQueue" />
>            <process ref="mesageGenerator" />
>             ....
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-stops-consuming-from-jms-queue-after-several-stop-resume-tp3345172p3345172.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/