Hi

Sending back a reply message from an exception depends if the
component support that. For example the jms component has a
transferException option you must enable.
http://camel.apache.org/jms

Usually you may want to handle the exception using .handle(true) and
then transform the message to some error message that the client
understands.

Also often you do not want to return a stacktrace as a response that
shows inner details of your app, hence why you may need to handle the
exception and transform into some error message of yours.

On Mon, Jul 21, 2014 at 5:01 PM, Jon Mithe <[email protected]> wrote:
> Thanks, Yeah I'm reading Camel in action, Camel cookbook and EIP.  I'm
> looking into request-reply and in particular what happens if the server
> making the reply encounters an unexpected exception.
>
> I think I'm not quite getting how to do inOut well from both sides and
> handle the errors.  I cant find that much documentation / examples about in
> out (a few pages in book, camel website pag).  For example,
> http://camel.apache.org/request-reply.html has a bit about request reply but
> all the rules are just sending a message out from what I see.
>
> For example this more real world problem:
>
>    queue where data comes in -> process it -> request external server to
> save data -> external server saves data ->  external server replies with a
> receipt number -> server handles receipt number
>
> So there's 2 applications, I would guess one with a route like:
>
>   from(data)
>        .process(data_process)
>        .inOut(external_server)
>        .to(reciept_queue)
>
> and the other server with a route like:
>
>  from(save_requests)
>       .process(process_to_save)
>       .bean(save_data_and_set_in_message_to_receipt)
>
> I've written that and it seems to work fine, however,  if process_to_save
> throws an error then the app making the request gets no reply / indication
> of error and eventually just times out.
>
> I though if the camel channel poking the process doesn't handle the
> expression, it gives it up the the caller, and that flows back to the
> ultimate caller. But that seems to be cut off at the inOut, i.e. its not
> sending a reply back saying fail.
>
> So I understand now that maybe some more exception handling should be
> happening on the server saving the data, so I can add an exceptionHander:
>
>  from(save_requests)
>       .onException(Exception.class).transform(constant("failed reciept").?
>       .process(process_to_save)
>       .bean(save_data_and_set_in_message_to_receipt)
>
> but I cant seem to find a way of returning the message back on the exchange
> / seemingly redirect it to a dead letter type queue.
>
> It seems possible that I could reference back to the server, however, with
> say netty I cant see a way of getting the consumer and producer for the same
> endpoint.
>
> I have the feeling I'm being an idiot here in some way...  Struggling to
> find documentation / examples on this sort of things that arn't a handful of
> lines long / incomplete.
>
> Anyways I'm plugging away at it still, any help would be most appreciated.
> I've been trying to do this within one camel context which I believe should
> still work (the 2 routes in my original post) but I may just write a couple
> of applications like the real world problem I just described.
>
> Thanks,
> Jon
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Exception-handling-tp5754013p5754155.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to