You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Vyacheslav Boyko <ma...@gmail.com> on 2022/06/28 14:16:58 UTC
FluentProducerTemplate hides exceptions?
Hello.
My case is very simple at the first sight.
I have a couple of chained routes. All of them are "direct".
Picture it like
from("direct://start")
.bean(this, "method1")
.to("direct://step1");
from("direct://step1")
.bean(this, "method2");
And I send my data two different ways:
1) using producerTemplate.sendBody("direct://start", aPayload(),
"header1", aHeader())
2) using
fluentProducerTemplate.to("direct://start").withHeader("header",
aHeader()).withBody(aPayload())
In both cases I throw an exception (my business-logic exception, e.g.
MyException.class) from inside this.method1() or this.method2().
In my test I make the following check:
test() {
// given
Throwable exceptionClass = ... // passing to test in parameters
- test specific argument
Throwable check = null;
camelContext.start();
try {
doSendPayloadWithProducer(); // 1 - using producerTemplate,
2 - using fluentProducerTemplate
} catch (Exception e) {
check = e;
while (null != check.getCause()) {
check = check.getCause();
}
} finally {
camelContext.stop();
}
Assertions.assertEquals(exceptionClass, check.getClass());
}
In case of using producerTemplate my exception is throwing out and I am
able to catch it the described way.
In case of using fluentProducerTemplate my call does not bubble it
outside the route (if I could say so). My catch clause does catches
nothing in this case.
Why do I see such different behavior?
--
Vyacheslav Boyko
mailto:mail4bvn@gmail.com