camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Exception not getting caught and multiple consumers getting the same message
Date Mon, 03 Oct 2011 07:48:31 GMT
Hi

You need to add <handled><constant>true</constant></handled> to your
<onException> to indicate you are handling this exception.


On Sun, Oct 2, 2011 at 2:57 PM, Aaron Doyle <a_r_doyle@yahoo.com> wrote:
> Sorry bout that, hopefully this is better.
>
>
> Message body
>
> <beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/springhttp://camel.apache.org/schema/spring/camel-spring.xsd";>
>
> <beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>         <property name="placeholderPrefix"value="${">
>         <property name="placeholderSuffix"value="}">
>         <property name="locations">
>             <value>classpath:environment.properties<value>
>         <property>
> </bean>
>
> <camelContext id="camel"xmlns="http://camel.apache.org/schema/spring">
>         <onException>
>             <exception>java.lang.Exception<exception>
>             <redeliveryPolicy  maximumRedeliveries="2" logStackTrace="true"
logRetryAttempted="true">
>             <to uri="activemq:queue:loadableFailure">
>         <onException>
>
>         <routeid="loaderRoute">
>             <from uri="activemq:queue:loadable">
>             <to uri="bean:loaderServiceClient?method=invokeService">
>         <route>
> <camelContext>
>
> <bean id="loaderServiceClient"class="com.tms.relay.ws.loader.client.LoaderServiceClient">
>
> <bean id="jmsConnectionFactory"c lass="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL"value="${messageQueueURI}">
> <bean>
>
> <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property  name="maxConnections"  value="50">
>         <property  name="maximumActive"  value="500">
>         <property  name="connectionFactory"  ref="jmsConnectionFactory">
> <bean>
>
> <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
>         <property  name="connectionFactory"  ref="pooledConnectionFactory">
>         <property  name="concurrentConsumers"  value="50">
> <bean>
>
> <bean  id="activemq"class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property   name="configuration"  ref="jmsConfig">
> <bean>
>
> <beans>
>
>
> ________________________________
> From: Claus Ibsen <claus.ibsen@gmail.com>
> To: users@camel.apache.org
> Sent: Sunday, October 2, 2011 3:08 AM
> Subject: Re: Exception not getting caught and multiple consumers getting the same message
>
> Hi
>
> Can you post the XML so its readable :)
>
>
> On Sat, Oct 1, 2011 at 6:40 PM, Aaron Doyle <a_r_doyle@yahoo.com> wrote:
>> I have a small route that reads from an activemq queue and sends the message to a
bean, a service client that calls a web service, and am experiencing a few issues.  The onException
configuration doesn't seem to get called when the bean throws an exception, and it seems like
some of my concurrent consumers are getting the same message off the queue.  The queue is
preloaded with 500 unique messages, the messages are eventually being loaded to a database,
the exception being thrown states that a duplicate key was being inserted, which could only
happen if two consumers picked up the same message ( I think ). After all 500 messages are
processed, I end up with ~495 in the database and 5 missing (not on the failure queue defined
by the onException.
>>
>> I am using ActiveMQ 5.4.1, Camel 2.8.1, Java 1.6.25, Spring 3.0.5 and Spring WS 2.0.1.
>>
>> Here is my configuration:
>>
>> *Note: I am able to catch the exception if I explicitly put a doTry and doCatch around
the to endpoint in my route.  Also, everything works and loads into my db fine if I use
1 or 2 consumers.
>>
>> <beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
>> http://camel.apache.org/schema/spring
>>
>   http://camel.apache.org/schema/spring/camel-spring.xsd"xsi:schemaLocation="> <beanid="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><propertyname="placeholderPrefix"value="${"/><propertyname="placeholderSuffix"value="}"/> <camelContextid="camel"xmlns="http://camel.apache.org/schema/spring">    <onException>        <exception>java.lang.Exception</exception>        <redeliveryPolicymaximumRedeliveries="2"logStackTrace="true"logRetryAttempted="true"/>        <touri="activemq:queue:loadableFailure"/>     <routeid="loaderRoute">        <fromuri="activemq:queue:loadable"/>        <touri="bean:loaderServiceClient?method=invokeService"/>    </route>  <beanid="jmsConnectionFactory"class="org.apache.activemq.ActiveMQConnectionFactory">    <propertyname="brokerURL"value="${messageQueueURI}"/> <beanid="pooledConnectionFactory"class="org.apache.activem
>> q.pool.PooledConnectionFactory">    <propertyname="maxConnections"value="50"/>    <propertyname="maximumActive"value="500"/>    <propertyname="connectionFactory"ref="jmsConnectionFactory"/> <beanid="jmsConfig"class="org.apache.camel.component.jms.JmsConfiguration">    <propertyname="connectionFactory"ref="pooledConnectionFactory"/>    <propertyname="concurrentConsumers"value="50"/> <beanid="activemq"class="org.apache.activemq.camel.component.ActiveMQComponent"> </beans>    <propertyname="configuration"ref="jmsConfig"/></bean></bean></bean></bean><beanid="loaderServiceClient"class="com.tms.relay.ws.loader.client.LoaderServiceClient"/></camelContext>    </onException><propertyname="locations"><value>classpath:environment.properties</value></property></bean>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/



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

Mime
View raw message