You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Joe Gottman <jo...@comcast.net> on 2009/06/18 14:59:13 UTC

Catching errors from "from" endpoints

   Suppose I have a route that begins with something like 

       from("file://c:\foo\bar")

and I want to catch and handle any Exceptions thrown from this endpoint.  Is
there any way to do this?  I can surround a subsequent "to" in a "doTry" ...
"doCatch" block, but there doesn't seem to be any way to do this for the
"from" clause.  Am I missing something, or is this a problem with the DSL?
-- 
View this message in context: http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24092503.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: Catching errors from "from" endpoints

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 23, 2009 at 4:04 AM, Joe Gottman <jo...@comcast.net>wrote:

>
>
>
> Claus Ibsen-2 wrote:
> >
> > On Thu, Jun 18, 2009 at 2:59 PM, Joe Gottman
> > <jo...@comcast.net>wrote:
> >
> >>
> >>   Suppose I have a route that begins with something like
> >>
> >>       from("file://c:\foo\bar")
> >>
> >> and I want to catch and handle any Exceptions thrown from this endpoint.
> >>  Is
> >> there any way to do this?  I can surround a subsequent "to" in a "doTry"
> >> ...
> >> "doCatch" block, but there doesn't seem to be any way to do this for the
> >> "from" clause.  Am I missing something, or is this a problem with the
> >> DSL?
> >
> >
> > Hi
> >
> > All the error handling in Camel such as onException, dead letter channel
> > kicks in when an exchange is created and routed.
> > So if an exception occurs beforehand such as inside the file consumer (eg
> > a
> > bug in Camel) then the component itself has a mechanism to handle that.
> >
> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24092503.html
> >> Sent from the Camel Development mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
>    But a Producer, especially a polling Producer, can fail after it is
> started.  For instance, a file producer like
>    from("file://H:/foo")
>
> could fail because the network connection to the H: drive was lost.  Is
> there any way to set up the route to handle that?
>

No you can use the ErrorHandler on the Consumer to handle this exception.
>From this ErrorHandler you can send a message to a route to let it handle
it, however its not like a first class DSL error handling with the
onException etc.

As the DSL error handling is when an Exchange (= Message) have been created
and then there is a failure when routing this message.

The consumer on the other hand fails before an Exchange (= Message) have
been created and thus the DSL error handling cannot be used here.

The consumer is also scheduled so it will try again on next poll.






>
> --
> View this message in context:
> http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24158601.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Catching errors from "from" endpoints

Posted by Joe Gottman <jo...@comcast.net>.


Claus Ibsen-2 wrote:
> 
> On Thu, Jun 18, 2009 at 2:59 PM, Joe Gottman
> <jo...@comcast.net>wrote:
> 
>>
>>   Suppose I have a route that begins with something like
>>
>>       from("file://c:\foo\bar")
>>
>> and I want to catch and handle any Exceptions thrown from this endpoint.
>>  Is
>> there any way to do this?  I can surround a subsequent "to" in a "doTry"
>> ...
>> "doCatch" block, but there doesn't seem to be any way to do this for the
>> "from" clause.  Am I missing something, or is this a problem with the
>> DSL?
> 
> 
> Hi
> 
> All the error handling in Camel such as onException, dead letter channel
> kicks in when an exchange is created and routed.
> So if an exception occurs beforehand such as inside the file consumer (eg
> a
> bug in Camel) then the component itself has a mechanism to handle that.
> 
> 
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24092503.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>>
> 
> 

   But a Producer, especially a polling Producer, can fail after it is
started.  For instance, a file producer like 
    from("file://H:/foo")

could fail because the network connection to the H: drive was lost.  Is
there any way to set up the route to handle that?

-- 
View this message in context: http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24158601.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: Catching errors from "from" endpoints

Posted by Claus Ibsen <cl...@gmail.com>.
But often you can just do a
from(file)
.onException(Exception)

Or a

from
doTry
  ...
doCatch(Exception)

That will catch any exception occurred during routing an Exchange.


On Mon, Jun 22, 2009 at 6:51 AM, Claus Ibsen <cl...@gmail.com> wrote:

>
>
> On Thu, Jun 18, 2009 at 2:59 PM, Joe Gottman <jo...@comcast.net>wrote:
>
>>
>>   Suppose I have a route that begins with something like
>>
>>       from("file://c:\foo\bar")
>>
>> and I want to catch and handle any Exceptions thrown from this endpoint.
>>  Is
>> there any way to do this?  I can surround a subsequent "to" in a "doTry"
>> ...
>> "doCatch" block, but there doesn't seem to be any way to do this for the
>> "from" clause.  Am I missing something, or is this a problem with the DSL?
>
>
> Hi
>
> All the error handling in Camel such as onException, dead letter channel
> kicks in when an exchange is created and routed.
> So if an exception occurs beforehand such as inside the file consumer (eg a
> bug in Camel) then the component itself has a mechanism to handle that.
>
> All consumers (well those that extends DefaultConsumer) have a
> fallback ExceptionHandler (org.apache.camel.spi.ExceptionHandler) that
> handles all
> thrown exception (that gets propagated back). By default its just a logger
> handler. But you can configure your own implementation.
>
> There is a setter for this parameter on the Consumer.
>
>
>
> B
>
>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24092503.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Catching errors from "from" endpoints

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 18, 2009 at 2:59 PM, Joe Gottman <jo...@comcast.net>wrote:

>
>   Suppose I have a route that begins with something like
>
>       from("file://c:\foo\bar")
>
> and I want to catch and handle any Exceptions thrown from this endpoint.
>  Is
> there any way to do this?  I can surround a subsequent "to" in a "doTry"
> ...
> "doCatch" block, but there doesn't seem to be any way to do this for the
> "from" clause.  Am I missing something, or is this a problem with the DSL?


Hi

All the error handling in Camel such as onException, dead letter channel
kicks in when an exchange is created and routed.
So if an exception occurs beforehand such as inside the file consumer (eg a
bug in Camel) then the component itself has a mechanism to handle that.

All consumers (well those that extends DefaultConsumer) have a
fallback ExceptionHandler (org.apache.camel.spi.ExceptionHandler) that
handles all
thrown exception (that gets propagated back). By default its just a logger
handler. But you can configure your own implementation.

There is a setter for this parameter on the Consumer.



B


>
> --
> View this message in context:
> http://www.nabble.com/Catching-errors-from--%22from%22-endpoints-tp24092503p24092503.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus