[
https://issues.apache.org/jira/browse/CAMEL-17507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17478016#comment-17478016
]
ldawson commented on CAMEL-17507:
---------------------------------
[~davsclaus] Thanks for the follow-up. Should've mentioned that I also checked
the response to no avail. When I look at the response in the Future<Exchange>,
I still see no indication that there was an exception. Doing the following
produces null output for both:
{code:java}
Future<Exchange> exchangeFuture = producerTemplate
.to(ERROR_GENERATOR_CHANNEL)
.withBody("Hello World")
.asyncSend();
Exchange exchange = exchangeFuture.get();
System.out.println("Exception: " + exchange.getException());
System.out.println("Handled exception: " +
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class));{code}
Seems like the Future might be prematurely returning:
{code:java}
2022-01-18 08:20:44.552 INFO 49590 --- [ main]
com.example.camel.errors.AppCamelErrors : Starting application bootstrapping...
Exception: null
Handled exception: null
2022-01-18 08:20:44.562 INFO 49590 --- [ main]
com.example.camel.errors.AppCamelErrors : Started AppCamelErrors in 2.915
seconds (JVM running for 3.575)
Received message 2: Hello World
Received message 1: Hello World
2022-01-18 08:20:45.561 DEBUG 49590 --- [error-generator]
o.a.camel.processor.MulticastProcessor : Message exchange has failed:
Multicast processing failed for number 0 for exchange: Exchange[] Exception:
java.lang.NullPointerException: Error generated
2022-01-18 08:20:45.561 DEBUG 49590 --- [error-generator]
o.a.camel.processor.MulticastProcessor : Message exchange has failed:
Multicast processing failed for number 0 for exchange: Exchange[] Exception:
java.lang.NullPointerException: Error generated
{code}
Seems like there might be a bug here.
> No error handler invoked on exception with multipleConsumer=true and POJO
> @Consume Annotation
> ---------------------------------------------------------------------------------------------
>
> Key: CAMEL-17507
> URL: https://issues.apache.org/jira/browse/CAMEL-17507
> Project: Camel
> Issue Type: Bug
> Affects Versions: 3.14.0
> Reporter: ldawson
> Priority: Major
>
> I've been trying to figure out how route errors to my own error handler with
> the following, seemingly simple configuration, but Camel is swallowing the
> exception without routing it to any error handler I configure. I've run out
> of ideas. Any help would be much appreciated.
> I've got a seda route that supports multiple consumers:
> {code:java}
> @Component
> public class MessageGenerator {
> public static final String ERROR_GENERATOR_CHANNEL =
> "seda:my-error-generator?multipleConsumers=true&concurrentConsumers=3";
> private final FluentProducerTemplate producerTemplate;
> public MessageGenerator(FluentProducerTemplate producerTemplate) {
> this.producerTemplate = producerTemplate;
> }
> public void generateMessage() {
> producerTemplate
> .to(ERROR_GENERATOR_CHANNEL)
> .withBody("Hello World")
> .asyncSend();
> }
> }{code}
>
> I've got two separate POJO consumers:
> {code:java}
> @Configuration
> public class MessageConsumer1 {
> @Consume(ERROR_GENERATOR_CHANNEL)
> void receiveMessage(String message) {
> System.out.println("Received message 1: " + message);
> throw new NullPointerException("Error generated");
> }
> }{code}
> {code:java}
> @Configuration
> public class MessageConsumer2 {
> @Consume(ERROR_GENERATOR_CHANNEL)
> void receiveMessage(String message) {
> System.out.println("Received message 2: " + message);
> }
> }{code}
>
> When I run the following example, the `NullPointerException` gets swallowed
> by the underlying Camel `MulticastProcessor` as we can see in the debug logs:
> {code:java}
> Received message 2: Hello World
> Received message 1: Hello World
> 2022-01-15 13:40:23.711 DEBUG 32945 — [error-generator]
> o.a.camel.processor.MulticastProcessor : Message exchange has failed:
> Multicast processing failed for number 0 for exchange: Exchange[] Exception:
> java.lang.NullPointerException: Error generated
> 2022-01-15 13:40:23.711 DEBUG 32945 — [error-generator]
> o.a.camel.processor.MulticastProcessor : Message exchange has failed:
> Multicast processing failed for number 0 for exchange: Exchange[] Exception:
> java.lang.NullPointerException: Error generated {code}
>
> The exception only gets logged as debug and never gets propagated to any
> error handler I set up.
> *Any thoughts on how I could receive the error in my own error handler rather
> than Camel swallowing the exception as a debug statement? Seems like there
> may be a bug here.*
> *Note1:* I've attempted many variations on both default error handling and
> default dead letter handling to no avail. I could just be doing it wrong...
> *Note2:* that I'm using Spring[Boot] here too, hence the `@Configuration`
> annotation.
> Note3: I've created a stack overflow question for this[
> here|https://stackoverflow.com/questions/70725713/camel-no-error-handler-invoked-on-exception-with-multipleconsumer-true-and-pojo].
--
This message was sent by Atlassian Jira
(v8.20.1#820001)