[
https://issues.apache.org/jira/browse/CAMEL-17507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-17507.
---------------------------------
Resolution: Fixed
docs updated
> 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: Task
> Components: documentation
> Affects Versions: 3.14.0
> Reporter: ldawson
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 3.19.0
>
>
> 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.10#820010)