You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "raulvk.soa" <ra...@gmail.com> on 2008/10/07 19:51:14 UTC

Exception Handling

Hi everyone,

I have an integration flow composed of two camel routes.

The first route validates the incoming message against an XML schema,
transforms it and sends it forth to the second route.

The second route validates the message against an XML Schema and if the
result is a pass, sends the message over to another endpoint. However, if
the validation fails, there is an exception(ValidationException.class)...
instruction that captures the exception and does the following processing:
logs it and creates an error reply message, which is sent back to the first
route.

However, what happens is that when the first route receives this reply
message, it triggers its own Exception handling mechanism (another
exception(ValidationException.class)... instruction), handling the message
again. Its like the Exception is being propagated back!

This behaviour is not what I expected, since the Exception was already dealt
with accordingly by the route that was responsible for it when the error was
raised..... So my question is, how can I remove the Exception information
from the Exchange before it is sent back to route 1, so that the reply is
not interpreted as an Exception again?

Also, another odd behaviour that I am experiencing is that if I set the
following at the top of my route: errorHandler(noErrorHandler());   none of
the configured exception(...) statements are triggered in case of an
exception. Why is this? Are both statements exclusive?

Many thanks!!

Raul.



-- 
View this message in context: http://www.nabble.com/Exception-Handling-tp19863662s22882p19863662.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Exception Handling

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi Sorry

I got 5 min before a meeting and is on a coffee break.

An Exchange has a setException method. And a isFailed() method that is used to determine if the exchange is OK or NOT.

What you need to do is to patch the DeadLetterChannel to not call the restoreException() ... let me find the code:

Line: 156 in trunk:
                restoreExceptionOnExchange(exchange);

Should not be used in your code.

    public static void restoreExceptionOnExchange(Exchange exchange) {
        exchange.setException(exchange.getProperty(FAILURE_HANDLED_PROPERTY, Throwable.class));
    }

You can subclass DeadLetterChannel and override the above method, where you do NOTHING.

Then use YOUR class instead of the default DeadLetterChannel


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 9. oktober 2008 12:00
To: camel-user@activemq.apache.org
Subject: RE: Exception Handling


Hi,

Any further insight on this?

Cheers!


raulvk.soa wrote:
> 
> Hi Claus,
> 
> Thanks for your reply.
> 
> With respect to 1), how is an Exchange marked as an Exception? What
> exactly indicates that an Exchange has incurred in an Exception? Some
> property, some header, etc.?
> 
> We need to get this development out soon, so we can't afford to wait until
> v1.5. However, what comes to mind is that as a temporary solution we might
> be able to create a Processor that deletes the properties/headers/whatever
> that indicates that a message is an Exception, so that it is not processed
> again by the Exception Handlers on the first route?
> 
> With respect to 2), basically I was just testing how the presence of an
> errorHandler influences the exception handlers. The errorHandler is
> defined at the top of my route, and the exception handlers are stated just
> before the routing logic that can throw the exception. Essentially:
> 
> errorHandler(noErrorHandler());
> 
> from("xx").pipeline("a", "b", "c");
> 
> exception(ValidationException.class)....
> 
> from("direct:a").to("validator:...");
> 
> from("direct:b")....
> 
> from("direct:c")....
> 
> What I would expect this code to do is handle the ValidationException as
> specified by the exception clause, whereas all other possible Exceptions
> should do nothing (noErrorHandler()).
> 
> Instead, what happens is that the exception() clause is completely ignored
> and even if a ValidationException is thrown, nothing happens.
> 
> Cheers!
> 
> 
> 
> Claus Ibsen wrote:
>> 
>> Hi Raul
>> 
>> Nice description of the problem. 
>> 
>> 1)
>> I think you are hitting the problem that we have tracked in JIRA as:
>> http://issues.apache.org/activemq/browse/CAMEL-960
>> 
>> As this is the 2nd or 3rd end-user hitting this, I think it's a must to
>> get in Camel 1.5. Hadrian is working on it.
>> 
>> If possible please add a comment on the ticket and point to this forum
>> thread using eg. a link from nabble. Then Hadrian (the engineer) working
>> on this will see this one as well.
>> 
>> 
>> 2)
>> About the noErrorHandler. I think it basically does nothing. What is your
>> expections here? Could you show some routing code with an noErrorHandler
>> where you expect it to do something different that now?
>> 
>> 
>> 
>> Med venlig hilsen
>>  
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>> -----Original Message-----
>> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
>> Sent: 7. oktober 2008 19:51
>> To: camel-user@activemq.apache.org
>> Subject: Exception Handling
>> 
>> 
>> Hi everyone,
>> 
>> I have an integration flow composed of two camel routes.
>> 
>> The first route validates the incoming message against an XML schema,
>> transforms it and sends it forth to the second route.
>> 
>> The second route validates the message against an XML Schema and if the
>> result is a pass, sends the message over to another endpoint. However, if
>> the validation fails, there is an exception(ValidationException.class)...
>> instruction that captures the exception and does the following
>> processing:
>> logs it and creates an error reply message, which is sent back to the
>> first
>> route.
>> 
>> However, what happens is that when the first route receives this reply
>> message, it triggers its own Exception handling mechanism (another
>> exception(ValidationException.class)... instruction), handling the
>> message
>> again. Its like the Exception is being propagated back!
>> 
>> This behaviour is not what I expected, since the Exception was already
>> dealt
>> with accordingly by the route that was responsible for it when the error
>> was
>> raised..... So my question is, how can I remove the Exception information
>> from the Exchange before it is sent back to route 1, so that the reply is
>> not interpreted as an Exception again?
>> 
>> Also, another odd behaviour that I am experiencing is that if I set the
>> following at the top of my route: errorHandler(noErrorHandler());   none
>> of
>> the configured exception(...) statements are triggered in case of an
>> exception. Why is this? Are both statements exclusive?
>> 
>> Many thanks!!
>> 
>> Raul.
>> 
>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Exception-Handling-tp19863662s22882p19863662.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-Handling-tp19863662s22882p19895784.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Exception Handling

Posted by "raulvk.soa" <ra...@gmail.com>.
Hi,

Any further insight on this?

Cheers!


raulvk.soa wrote:
> 
> Hi Claus,
> 
> Thanks for your reply.
> 
> With respect to 1), how is an Exchange marked as an Exception? What
> exactly indicates that an Exchange has incurred in an Exception? Some
> property, some header, etc.?
> 
> We need to get this development out soon, so we can't afford to wait until
> v1.5. However, what comes to mind is that as a temporary solution we might
> be able to create a Processor that deletes the properties/headers/whatever
> that indicates that a message is an Exception, so that it is not processed
> again by the Exception Handlers on the first route?
> 
> With respect to 2), basically I was just testing how the presence of an
> errorHandler influences the exception handlers. The errorHandler is
> defined at the top of my route, and the exception handlers are stated just
> before the routing logic that can throw the exception. Essentially:
> 
> errorHandler(noErrorHandler());
> 
> from("xx").pipeline("a", "b", "c");
> 
> exception(ValidationException.class)....
> 
> from("direct:a").to("validator:...");
> 
> from("direct:b")....
> 
> from("direct:c")....
> 
> What I would expect this code to do is handle the ValidationException as
> specified by the exception clause, whereas all other possible Exceptions
> should do nothing (noErrorHandler()).
> 
> Instead, what happens is that the exception() clause is completely ignored
> and even if a ValidationException is thrown, nothing happens.
> 
> Cheers!
> 
> 
> 
> Claus Ibsen wrote:
>> 
>> Hi Raul
>> 
>> Nice description of the problem. 
>> 
>> 1)
>> I think you are hitting the problem that we have tracked in JIRA as:
>> http://issues.apache.org/activemq/browse/CAMEL-960
>> 
>> As this is the 2nd or 3rd end-user hitting this, I think it's a must to
>> get in Camel 1.5. Hadrian is working on it.
>> 
>> If possible please add a comment on the ticket and point to this forum
>> thread using eg. a link from nabble. Then Hadrian (the engineer) working
>> on this will see this one as well.
>> 
>> 
>> 2)
>> About the noErrorHandler. I think it basically does nothing. What is your
>> expections here? Could you show some routing code with an noErrorHandler
>> where you expect it to do something different that now?
>> 
>> 
>> 
>> Med venlig hilsen
>>  
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>> -----Original Message-----
>> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
>> Sent: 7. oktober 2008 19:51
>> To: camel-user@activemq.apache.org
>> Subject: Exception Handling
>> 
>> 
>> Hi everyone,
>> 
>> I have an integration flow composed of two camel routes.
>> 
>> The first route validates the incoming message against an XML schema,
>> transforms it and sends it forth to the second route.
>> 
>> The second route validates the message against an XML Schema and if the
>> result is a pass, sends the message over to another endpoint. However, if
>> the validation fails, there is an exception(ValidationException.class)...
>> instruction that captures the exception and does the following
>> processing:
>> logs it and creates an error reply message, which is sent back to the
>> first
>> route.
>> 
>> However, what happens is that when the first route receives this reply
>> message, it triggers its own Exception handling mechanism (another
>> exception(ValidationException.class)... instruction), handling the
>> message
>> again. Its like the Exception is being propagated back!
>> 
>> This behaviour is not what I expected, since the Exception was already
>> dealt
>> with accordingly by the route that was responsible for it when the error
>> was
>> raised..... So my question is, how can I remove the Exception information
>> from the Exchange before it is sent back to route 1, so that the reply is
>> not interpreted as an Exception again?
>> 
>> Also, another odd behaviour that I am experiencing is that if I set the
>> following at the top of my route: errorHandler(noErrorHandler());   none
>> of
>> the configured exception(...) statements are triggered in case of an
>> exception. Why is this? Are both statements exclusive?
>> 
>> Many thanks!!
>> 
>> Raul.
>> 
>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Exception-Handling-tp19863662s22882p19863662.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-Handling-tp19863662s22882p19895784.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Exception Handling

Posted by "raulvk.soa" <ra...@gmail.com>.
Hi Claus,

Thanks for your reply.

With respect to 1), how is an Exchange marked as an Exception? What exactly
indicates that an Exchange has incurred in an Exception? Some property, some
header, etc.?

We need to get this development out soon, so we can't afford to wait until
v1.5. However, what comes to mind is that as a temporary solution we might
be able to create a Processor that deletes the properties/headers/whatever
that indicates that a message is an Exception, so that it is not processed
again by the Exception Handlers on the first route?

With respect to 2), basically I was just testing how the presence of an
errorHandler influences the exception handlers. The errorHandler is defined
at the top of my route, and the exception handlers are stated just before
the routing logic that can throw the exception. Essentially:

errorHandler(noErrorHandler());

from("xx").pipeline("a", "b", "c");

exception(ValidationException.class)....

from("direct:a").to("validator:...");

from("direct:b")....

from("direct:c")....

What I would expect this code to do is handle the ValidationException as
specified by the exception clause, whereas all other possible Exceptions
should do nothing (noErrorHandler()).

Instead, what happens is that the exception() clause is completely ignored
and even if a ValidationException is thrown, nothing happens.

Cheers!



Claus Ibsen wrote:
> 
> Hi Raul
> 
> Nice description of the problem. 
> 
> 1)
> I think you are hitting the problem that we have tracked in JIRA as:
> http://issues.apache.org/activemq/browse/CAMEL-960
> 
> As this is the 2nd or 3rd end-user hitting this, I think it's a must to
> get in Camel 1.5. Hadrian is working on it.
> 
> If possible please add a comment on the ticket and point to this forum
> thread using eg. a link from nabble. Then Hadrian (the engineer) working
> on this will see this one as well.
> 
> 
> 2)
> About the noErrorHandler. I think it basically does nothing. What is your
> expections here? Could you show some routing code with an noErrorHandler
> where you expect it to do something different that now?
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
> Sent: 7. oktober 2008 19:51
> To: camel-user@activemq.apache.org
> Subject: Exception Handling
> 
> 
> Hi everyone,
> 
> I have an integration flow composed of two camel routes.
> 
> The first route validates the incoming message against an XML schema,
> transforms it and sends it forth to the second route.
> 
> The second route validates the message against an XML Schema and if the
> result is a pass, sends the message over to another endpoint. However, if
> the validation fails, there is an exception(ValidationException.class)...
> instruction that captures the exception and does the following processing:
> logs it and creates an error reply message, which is sent back to the
> first
> route.
> 
> However, what happens is that when the first route receives this reply
> message, it triggers its own Exception handling mechanism (another
> exception(ValidationException.class)... instruction), handling the message
> again. Its like the Exception is being propagated back!
> 
> This behaviour is not what I expected, since the Exception was already
> dealt
> with accordingly by the route that was responsible for it when the error
> was
> raised..... So my question is, how can I remove the Exception information
> from the Exchange before it is sent back to route 1, so that the reply is
> not interpreted as an Exception again?
> 
> Also, another odd behaviour that I am experiencing is that if I set the
> following at the top of my route: errorHandler(noErrorHandler());   none
> of
> the configured exception(...) statements are triggered in case of an
> exception. Why is this? Are both statements exclusive?
> 
> Many thanks!!
> 
> Raul.
> 
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Exception-Handling-tp19863662s22882p19863662.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-Handling-tp19863662s22882p19874847.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Exception Handling

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi Raul

Nice description of the problem. 

1)
I think you are hitting the problem that we have tracked in JIRA as:
http://issues.apache.org/activemq/browse/CAMEL-960

As this is the 2nd or 3rd end-user hitting this, I think it's a must to get in Camel 1.5. Hadrian is working on it.

If possible please add a comment on the ticket and point to this forum thread using eg. a link from nabble. Then Hadrian (the engineer) working on this will see this one as well.


2)
About the noErrorHandler. I think it basically does nothing. What is your expections here? Could you show some routing code with an noErrorHandler where you expect it to do something different that now?



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 7. oktober 2008 19:51
To: camel-user@activemq.apache.org
Subject: Exception Handling


Hi everyone,

I have an integration flow composed of two camel routes.

The first route validates the incoming message against an XML schema,
transforms it and sends it forth to the second route.

The second route validates the message against an XML Schema and if the
result is a pass, sends the message over to another endpoint. However, if
the validation fails, there is an exception(ValidationException.class)...
instruction that captures the exception and does the following processing:
logs it and creates an error reply message, which is sent back to the first
route.

However, what happens is that when the first route receives this reply
message, it triggers its own Exception handling mechanism (another
exception(ValidationException.class)... instruction), handling the message
again. Its like the Exception is being propagated back!

This behaviour is not what I expected, since the Exception was already dealt
with accordingly by the route that was responsible for it when the error was
raised..... So my question is, how can I remove the Exception information
from the Exchange before it is sent back to route 1, so that the reply is
not interpreted as an Exception again?

Also, another odd behaviour that I am experiencing is that if I set the
following at the top of my route: errorHandler(noErrorHandler());   none of
the configured exception(...) statements are triggered in case of an
exception. Why is this? Are both statements exclusive?

Many thanks!!

Raul.



-- 
View this message in context: http://www.nabble.com/Exception-Handling-tp19863662s22882p19863662.html
Sent from the Camel - Users mailing list archive at Nabble.com.