You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2010/07/22 12:30:12 UTC

Re: Exception in the DeadLetterChannel causes message to be consumed

Hi

See this wiki page when asking for help.
http://camel.apache.org/support.html

See the first bullet!

Camel has 15+ released version so its hard to bother helping if you
don't report the version being used. And if you have tried newer
releases etc.


On Thu, Jul 22, 2010 at 12:24 PM, kumaap <am...@gmail.com> wrote:
>
> My scenario.
>
> consuming a message off a JMS queue and an exception happens, the message is
> routed to my DeadLetterChannel where it executes my custom failureProcessor
> which fails and throws an exception
> im finding that the exception just gets swallowed and the message gets
> consumed of the queue.
>
>
> Method
>
> RedeliveryErrorHandler.deliverToFailureProcessor
>
> try {
>        // store the last to endpoint as the failure endpoint
>        exchange.setProperty(Exchange.FAILURE_ENDPOINT,
> exchange.getProperty(Exchange.TO_ENDPOINT));
>        processor.process(exchange);
> } catch (Exception e) {
>        exchange.setException(e); <--- sets the new exception
> }
>
> then just carries on and ignores the exception and resets
>
> Method
> RedeliveryErrorHandler.prepareExchangeAfterFailure
>
> ExchangeHelper.setFailureHandled(exchange);
>
>        // honor if already set a handling
> boolean alreadySet = exchange.getProperty(Exchange.ERRORHANDLER_HANDLED) !=
> null;
> if (alreadySet) {
>        boolean handled = exchange.getProperty(Exchange.ERRORHANDLER_HANDLED,
> Boolean.class);
>        if (log.isDebugEnabled()) {
>                log.debug("This exchange has already been marked for handling: " +
> handled);
>        }
>        if (handled) {
>                exchange.setException(null);
>        } else {
>                // exception not handled, put exception back in the exchange
>
> exchange.setException(exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
> Exception.class));
>                // and put failure endpoint back as well
>                exchange.setProperty(Exchange.FAILURE_ENDPOINT,
> exchange.getProperty(Exchange.TO_ENDPOINT));
>        }
> return;
>
>
> What i want it to do is try and use the failureProcessor if that fails throw
> a Rutime exception and let camel reprocess the mesage.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1835181.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Exception in the DeadLetterChannel causes message to be consumed

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Camel does not swallow exceptions. Setting the exception on the
Exchange is how exceptions is represented in Camel. This is by design.
The consumer should check the Exchange if its failed and if there was
an exception by the getException method on the Exchange.

Can you provide a sample application with your route and which
demonstrates your issue?

And btw why are you using CLIENT ACK mode? Is there a special reason for that?
Using TRANSACTED allows the broker to rollback and re-submit the message.



On Thu, Jul 22, 2010 at 3:32 PM, kumaap <am...@gmail.com> wrote:
>
> Ive upgraded to 2.4
>
> and the same thing is still happing
>
> AsyncProcessorTypeConverter
>
> public boolean process(Exchange exchange, AsyncCallback callback) {
>            if (processor == null) {
>                // no processor then we are done
>                callback.done(true);
>                return true;
>            }
>            try {
>                processor.process(exchange);
>            } catch (Throwable e) {
>                // must catch throwable so we catch all
>                exchange.setException(e);   <-- Sets an exception when
> failure processor fails
>            } finally {
>                // we are bridging a sync processor as async so callback
> with true
>                callback.done(true);
>            }
>            return true;
>        }
>
> Then carries on and acts like nothing has happened. I cant see any code that
> checks if an exception happen in processing the failureProcessor
>
> Thanks in advance kumaap
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1842280.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Exception in the DeadLetterChannel causes message to be consumed

Posted by kumaap <am...@gmail.com>.
Ive upgraded to 2.4 

and the same thing is still happing 

AsyncProcessorTypeConverter

public boolean process(Exchange exchange, AsyncCallback callback) {
            if (processor == null) {
                // no processor then we are done
                callback.done(true);
                return true;
            }
            try {
                processor.process(exchange);
            } catch (Throwable e) {
                // must catch throwable so we catch all
                exchange.setException(e);   <-- Sets an exception when
failure processor fails  
            } finally {
                // we are bridging a sync processor as async so callback
with true
                callback.done(true);
            }
            return true;
        }

Then carries on and acts like nothing has happened. I cant see any code that
checks if an exception happen in processing the failureProcessor

Thanks in advance kumaap

-- 
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1842280.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in the DeadLetterChannel causes message to be consumed

Posted by kumaap <am...@gmail.com>.
Yes 
   <bean id="jms" class="org.apache.camel.component.jms.JMSComponent">
        <property name="acknowledgementModeName"
value="CLIENT_ACKNOWLEDGE"/>
        <property name="cacheLevelName" value="CACHE_CONSUMER"/>
        <property name="connectionFactory" ref="physConnectionFactory"/>        
    </bean>

Im not using any spring transactions.

I have created my own Error handler and forced a Runtime exception 

    @Override
    protected void processErrorHandler(Exchange exchange, RedeliveryData
data) throws Exception
    {

        if(exchange.getException() == null)
        {
            return;
        }
        throw new RuntimeException("test");
    }

And it rollback the exchnages and retries.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1837100.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in the DeadLetterChannel causes message to be consumed

Posted by Claus Ibsen <cl...@gmail.com>.
And you are using transacted JMS ?


On Thu, Jul 22, 2010 at 12:34 PM, kumaap <am...@gmail.com> wrote:
>
> Sorry version 2.2 Camel
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1835865.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Exception in the DeadLetterChannel causes message to be consumed

Posted by kumaap <am...@gmail.com>.
Sorry version 2.2 Camel 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-the-DeadLetterChannel-causes-message-to-be-consumed-tp1835181p1835865.html
Sent from the Camel - Users mailing list archive at Nabble.com.