Files
spring-amqp-samples/spring-rabbit-global-errorhandler
Artem Bilan 7fd03cc725 Upgrade deps, including Maven Wrapper
* Re-enable `stocks` sample back for more coverage
2024-12-27 11:50:16 -05:00
..
2021-09-17 12:38:29 -04:00
2017-02-14 12:11:55 -05:00
2024-12-27 11:50:16 -05: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`