On Wed, Feb 22, 2012 at 12:02 PM, Alex Anderson <a...@frontlinesms.com> wrote:
> Thanks for the confirmation that this is ok, Claus.  Are there any
> other ways to do this within Camel, or would there otherwise need to
> be an external event listener to catch problems within the Endpoint?
>

There is a ExceptionHandler interface that consumers have by default.
That is usually configured to use the logging implementation. We do
not have exposed an easy way to configure and use a custom
implementation, as well how to configure a specific one in an endpoint
uri. We may do this in the future.

And we have in the past talked about allowing consumers to send empty
messages with exception into the routing engine, so people can use the
Camel error handler for that. There is an old JIRA ticket for that.

But in the end it will always be consumer specific how they deal with
initial errors, before they hand over a message to Camel.


> Alex
>
>
> On 22 February 2012 13:16, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> On Wed, Feb 22, 2012 at 8:59 AM, Alex Anderson <a...@frontlinesms.com> wrote:
>>> Hi Claus & Tuomas,
>>>
>>> I faced a similar problem a couple of weeks ago and came to the
>>> following solution:
>>>
>>> The exception can be passed to a route in the Consumer like so:
>>>
>>>        public void handleEndpointException(EndpointException ex) {
>>>                Exchange exchange = getEndpoint().createExchange();
>>>                exchange.setException(ex);
>>>                getProcessor().process(exchange);
>>>        }
>>>
>>> The exception can then be handled by an onException clause():
>>>
>>>        ...route-definition...
>>>        .onException(EndpointException)
>>>                        .handled(true)
>>>                        .beanRef("someService", "handleEndpointException")
>>>                        .end()
>>>
>>> And in someService, I have the following method:
>>>
>>>        def handleEndpointException(Exchange ex) {
>>>                EndpointException caughtException = (EndpointException)
>>> ex.getProperty(Exchange.EXCEPTION_CAUGHT);
>>>                ...
>>>        }
>>>
>>> Claus, please tell me if this is foolish!
>>>
>>
>> That is one way of doing it, mind that this requires end users to
>> setup the onException(EndpointException.class) to ensure they handled
>> that.
>>
>> Also it requires your consumers to implement this logic to support
>> this kind of error handling.
>>
>>
>>
>>
>>> Thanks,
>>>
>>> Alex
>>>
>>>
>>> On 22 February 2012 10:42, Claus Ibsen <claus.ib...@gmail.com> wrote:
>>>> Hi
>>>>
>>>> If you mean a consumer, such as eg
>>>> from("file:foo")
>>>>
>>>> Then that would be consumer specific how it validates and reports
>>>> mis-configuration.
>>>>
>>>> You cannot use the onException / dead letter channel for that. As its
>>>> like chicken-egg. You need a valid message in the Camel routing
>>>> engine, before onException / dead letter channel can be used.
>>>>
>>>>
>>>>
>>>> On Wed, Feb 22, 2012 at 8:28 AM, tkatva <tuomas.ka...@gmail.com> wrote:
>>>>> Hello
>>>>>
>>>>> Camel is great but one thing I am wondering is that is there a way to 
>>>>> catch
>>>>> a Endpoint exception ? For example if I am polling on a directory and the
>>>>> url is spelled wrong, can I catch that exception programmatically ? Or do
>>>>> just need to check the log for it ?
>>>>>
>>>>> Thank you
>>>>>
>>>>> Best Regards Tuomas Katva
>>>>>
>>>>> --
>>>>> View this message in context: 
>>>>> http://camel.465427.n5.nabble.com/Endpoint-exception-handling-tp5504378p5504378.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> FuseSource
>>>> Email: cib...@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: cib...@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: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to