Files
spring-amqp-samples/spring-rabbit-global-errorhandler
2022-04-18 10:13:37 -04:00
..
2020-09-16 09:39:42 -04:00
2017-02-14 12:11:55 -05:00
2022-04-18 10:13:37 -04:00

# Configuring a Global Error Handler for @RabbitListener s

This sample demonstrates how to add a global error handler to `@RabbitListener` methods.

It uses an auto-delete queue that will be removed after the demo completes.

The error handler is the same as the default (`ConditionalRejectingErrorHandler`) but with a custom `FatalExceptionStrategy`
that extends the default and logs the failed message.

NOTE: Such a simple handler is not generally needed since the framework will log the failed message itself; for a real
application, some additional action might be taken, for example write the bad message to a database.

A JSON message converter is used; the sample sends one "good" message, and one bad one, which fails message conversion.
Message conversion is considered fatal and the message is not requeued.

It is a Spring Boot application and can be run with normal boot run methods, e.g.: `./mvnw spring-boot:run`