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!
Thanks,
Alex
On 22 February 2012 10:42, Claus Ibsen <[email protected]> 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 <[email protected]> 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: [email protected]
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/