Hi Ashwin,

Thanks for your help on this.  I ended up solving this by creating an
Exchange with the Exception attached, like so:

The exception can be passed to a route in the Consumer like so:

       class MyConsumer { ...
              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);
               ...
       }

Alex


On 15 February 2012 18:32, Ashwin Karpe <aka...@fusesource.com> wrote:
> Hi,
>
> Hmm, This goes to whether routes are kinda self-directed, i.e., inability to
> produce messages to a destination brings down the route itself...
>
> While perfectly do-able, provided the consumer endpoint provides a
> capability to do so via a flag/switch, I would rather not employ this
> strategy. It would drive system admins crazy if routes were suddenly coming
> down of their own accord and require them to make secondary checks to see
> what happened. Too much power & chaos!!!...
>
> Ideally, you might want to delegate the ability to bring down routes to
> another bean/service/entity that could be notified on Connect Exceptions and
> then have it bring down the necessary routes gracefully.
>
> In the absence of that doing it directly in the exception handling route
> would also do the trick, albeit only within the boundaries of the Camel
> Context in which the exception is caught...
>
> Cheers,
>
> Ashwin...
>
> -----
> ---------------------------------------------------------
> Ashwin Karpe
> Apache Camel Committer & Sr Principal Consultant
> FUSESource (a Progress Software Corporation subsidiary)
> http://fusesource.com
>
> Blog: http://opensourceknowledge.blogspot.com
> ---------------------------------------------------------
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Handling-Endpoint-failure-tp5486157p5486388.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to