You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by juhasiltanen <ju...@gmail.com> on 2009/08/04 11:07:25 UTC
Re: Routing with RouteBuilder and onException, missing the
Exception instance
I am trying to get the custom exception at the point when the executions hits
my processor implementation, not during the route configuration.
I assume, that by invoking Exchange.getProperties a full Map of properties
is provided. Is this the case?
By iterating over the Map, only two properties are available: CamelBinding
and CamelBeanHolder.
I am using Camel 2.0 M3
Any more ideas?
-J-
Claus Ibsen-2 wrote:
>
> On Tue, Aug 4, 2009 at 9:27 AM, juhasiltanen<ju...@gmail.com>
> wrote:
>>
>> I have a simple routing configuration of
>> onException(MyException.class).to(myEndpoint)
>>
>> Then I have a simple implementation of a Processor interface reading from
>> myEndpoint (that receives an Exchange), let's call it MyProcessor.
>>
>> How do I get the instance of MyException thrown from the depths of the
>> application to MyProcessor?
>>
>> Exchange.getException returns null, and this is the place I would expect
>> MyException to be found.
>
> No its not as when you do routing in the onException then you handle it.
> You can get the caused exception from a property
>
> In Camel 2.0
> Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
> Exception.class);
>
> And its about the same in 1.x the key is different though
>
> See more here:
> http://camel.apache.org/exception-clause.html
>
> In the section "using a processor as failure handler"
>
>>
>> Thank's in advance!
>> --
>> View this message in context:
>> http://www.nabble.com/Routing-with-RouteBuilder-and-onException%2C-missing-the-Exception-instance-tp24803541p24803541.html
>> Sent from the Camel - Users 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
>
>
--
View this message in context: http://www.nabble.com/Routing-with-RouteBuilder-and-onException%2C-missing-the-Exception-instance-tp24803541p24804847.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Routing with RouteBuilder and onException, missing the
Exception instance
Posted by juhasiltanen <ju...@gmail.com>.
As it seems, the exchange can not be sent through a queue for processing
after an exception has occured.
Upon exception, the control needs to be passed directly to a processor. As I
am using spring beans with dependency injections, the route definition
needed to be changed from...
onException(...).to(queueEndpoint)
... to ...
onException(...).beanRef("beanName")
... and the CamelExceptionCaught property is available at the Exchange
instance.
thanks for your help!
-J-
juhasiltanen wrote:
>
> I am trying to get the custom exception at the point when the executions
> hits my processor implementation, not during the route configuration.
>
> I assume, that by invoking Exchange.getProperties a full Map of properties
> is provided. Is this the case?
>
> By iterating over the Map, only two properties are available: CamelBinding
> and CamelBeanHolder.
>
> I am using Camel 2.0 M3
>
> Any more ideas?
>
> -J-
>
>
> Claus Ibsen-2 wrote:
>>
>> On Tue, Aug 4, 2009 at 9:27 AM, juhasiltanen<ju...@gmail.com>
>> wrote:
>>>
>>> I have a simple routing configuration of
>>> onException(MyException.class).to(myEndpoint)
>>>
>>> Then I have a simple implementation of a Processor interface reading
>>> from
>>> myEndpoint (that receives an Exchange), let's call it MyProcessor.
>>>
>>> How do I get the instance of MyException thrown from the depths of the
>>> application to MyProcessor?
>>>
>>> Exchange.getException returns null, and this is the place I would expect
>>> MyException to be found.
>>
>> No its not as when you do routing in the onException then you handle it.
>> You can get the caused exception from a property
>>
>> In Camel 2.0
>> Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
>> Exception.class);
>>
>> And its about the same in 1.x the key is different though
>>
>> See more here:
>> http://camel.apache.org/exception-clause.html
>>
>> In the section "using a processor as failure handler"
>>
>>>
>>> Thank's in advance!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Routing-with-RouteBuilder-and-onException%2C-missing-the-Exception-instance-tp24803541p24803541.html
>>> Sent from the Camel - Users 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
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Routing-with-RouteBuilder-and-onException%2C-missing-the-Exception-instance-tp24803541p24805472.html
Sent from the Camel - Users mailing list archive at Nabble.com.