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 Tue, 11 Oct 2011 13:34:05 GMT
On Mon, Oct 10, 2011 at 8:04 PM, Aaron Doyle <a_r_doyle@yahoo.com> wrote:
> I figured out what the problem was, and the problem wasn't with Camel, it was me.  Was
doing something stupid in my web service that was causing the problem.  Thanks so much for
the quick responses and feedback.
>

Glad for sharing with us you found the cause of the problem.



> Best Regards,
> Aaron
>
>
> ________________________________
> From: Aaron Doyle <a_r_doyle@yahoo.com>
> To: "users@camel.apache.org" <users@camel.apache.org>; Aaron Doyle <a_r_doyle@yahoo.com>
> Sent: Friday, October 7, 2011 12:00 PM
> Subject: Re: Exception not getting caught and multiple consumers getting the same message
>
> my properties values did not display correctly, they are
> messageQueueURI=tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1
> loaderServiceURI=spring-ws:http://localhost:8080/LoaderService
>
>
>
> ________________________________
> From: Aaron Doyle <a_r_doyle@yahoo.com>
> To: "users@camel.apache.org" <users@camel.apache.org>
> Sent: Friday, October 7, 2011 11:55 AM
> Subject: Re: Exception not getting caught and multiple consumers getting the same message
>
> I tried the handleFault=true attribute and that did not enable the exceptions to get
caught.
>
> The exceptions are caught when running one consumer, as soon as I increase the number
of consumers, exceptions are not caught and messages start getting lost. I noticed that all
50 consumers are sharing the same connection, whereas I would think that all consumers get
there own connection...  Adding a doTry/doCatch around the 'to' section of my route, does
catch most of the exceptions but still some messages seem to get lost... Is there any way
with 1 consumer that I can process multiple messages asynchronously?  Or that I can force
each consumer to get its own connection?  Has anyone else experienced problems running multiple
consumers off a message queue and sending the messages to a spring-ws component?
>
>
> Here is my latest configuration:
> ** Note below 2 lines from my properites file.tcploaderServiceURIspring-ws:http://localhost:8080/LoaderService=://localhost:61616?jms.prefetchPolicy.queuePrefetch=1
>
>         <bean id="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>
>
>         <bean id="jmsConnectionFactory" class="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>
>
>         <camelContext id="camel" handleFault="true" xmlns="http://camel.apache.org/schema/spring">
>
>                 <endpoint id="loaderService" uri="${loaderServiceURI}"
/>
>
>                 <onException>
>                         <exception>java.lang.Exception</exception>
>                         <redeliveryPolicy redeliveryDelay="1000"
maximumRedeliveries="2" />
>                         <handled><constant>true</constant></handled>
>                         <to uri="activemq:queue:loadableFailure"
/>
>                 </onException>
>
>                 <route id="loaderWS">
>                         <from uri="activemq:queue:loadable"
/>
>                         <to ref="loaderService" />
>                 </route>
>
>         </camelContext>
>
>
> ________________________________
> From: Claus Ibsen <claus.ibsen@gmail.com>
> To: "users@camel.apache.org" <users@camel.apache.org>
> Sent: Tuesday, October 4, 2011 11:50 AM
> Subject: Re: Exception not getting caught and multiple consumers getting the same message
>
> Could it be the spring-ws client returns a SOAP Fault and not an exception?
> Camel error handler only reacts upon exceptions.
>
> There is a flag you can enable on the route, handleFault=true, that
> turns SOAP faults into exceptions,
> and allow Camel error handler to react then.
>
> On Mon, Oct 3, 2011 at 2:16 PM, Aaron Doyle <a_r_doyle@yahoo.com> wrote:
>> Hello,
>>
>> That did not seem to help fix my problem.  If I change my route to the
>> following, the exception is caught and sent to the loadable failure queue.
>>
>>         <route id="loaderRoute">
>>              <from uri="activemq:queue:loadable">
>>              <doTry>
>>                  <to uri="bean:loaderServiceClient?method=invokeService">
>>                  <doCatch>
>>                         <to uri="activemq:queue:loadableFailure"
/>
>>                  </doCatch>
>>             </doTry>
>>          <route>
>> Is there any way to do a redelivery with the doTry/doCatch?
>>
>> Back to the onException problem....
>> The problem seems to be specific to a spring ws client.  The bean
>> 'loaderServiceClient' is a spring ws client and the exceptions do not get
>> handled, if I replace the 'to' uri with
>> 'spring-ws:http://server.com:8080/service' the exception does not get
>> handled either.  If I replace the 'to' uri with a test pojo where the method
>> being called explicitly throws an exception, the exceptions are caught and
>> handled by the onException.  Is it possible that there is something in the
>> Spring WS Client that is eating the exception....
>>
>> Lastly, on the second part of my question from first email, does it seem
>> possible that I have multiple consumers grabbing the same message off of the
>> queue to load (which is what is causing the exception to be thrown.)  If I
>> run with 1 consumer, it runs without exceptions.
>>
>> -Aaron
>> From: Claus Ibsen <claus.ibsen@gmail.com>
>> To: users@camel.apache.org; Aaron Doyle <a_r_doyle@yahoo.com>
>> Sent: Monday, October 3, 2011 3:48 AM
>> Subject: Re: Exception not getting caught and multiple consumers getting the
>> same message
>>
>> 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"cl
>>> ass="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"><va
>>>> lue>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/
>>
>>
>>
>
>
>
> --
> 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/
>
>
>
> messageQueueURI=



-- 
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