You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vyacheslav Boyko <ma...@gmail.com> on 2021/06/22 10:24:59 UTC
What is the scope of route exception handling?
Hello!
As described into the documentation,
Exception handling may be global and per-route.
And my question is about the latest - per-route exception handling.
from("direct://" + QUEUE_START_ISSUE_CARD)
.bean(processor, "createRequest")
.onException(Exception.class).handled(true).useOriginalBody()
.to("direct:CHECK")
.end()
.to(hostCardServiceEndpoint)
.unmarshal().jaxb();
My route is to send a request to "hostCardServiceEndpoint". This
operation may produce an exceptinon. And my intention is to handle such
exceptions to perform a check operation.
My question is - where to place "onException" clause?
I want Camel to catch all other exceptions occurring in this route with
global exception handling strategy.
I guess the following options.
1) before the operation with potential exception?
from("direct://" + QUEUE_START_ISSUE_CARD)
.bean(processor, "createRequest")
.onException(Exception.class).handled(true).useOriginalBody()
.to("direct:CHECK")
.end()
.to(hostCardServiceEndpoint)
.unmarshal().jaxb();
2) after the operation with potential exception?
from("direct://" + QUEUE_START_ISSUE_CARD)
.bean(processor, "createRequest")
.to(hostCardServiceEndpoint)
.onException(Exception.class).handled(true).useOriginalBody()
.to("direct:CHECK")
.end()
.unmarshal().jaxb();
3) right after the route starts?
from("direct://" + QUEUE_START_ISSUE_CARD)
.onException(Exception.class).handled(true).useOriginalBody()
.to("direct:CHECK")
.end()
.bean(processor, "createRequest")
.to(hostCardServiceEndpoint)
.unmarshal().jaxb();
4) should I separate sending message to hostCardServiceEndpoint in
separated route to perform per-route exception handling?
5) Does it really mean in case of my "call" is CXF
(hostCardServiceEndpoint is "cxf://endpoint")?
Many thanks,
Vyacheslav Boyko.
mailto: mail4bvn@gmail.com