Files
spring-amqp-samples/spring-rabbit-global-errorhandler
Artem Bilan 97c51071d9 Upgrade dependencies; change logging to Log4j2 (#55)
* Upgrade dependencies; change logging to Log4j2

* * Fix dependency versions and modernize some of them

* * Bring `junit` dependency back into `spring-rabbit-stocks` sample
since it is an `optional` with `spring-rabbit-test`
* Remove `test` dependencies from `spring-rabbit-helloworld` sample
since there is no tests in this sample at all
2019-12-03 15:58:28 -05:00
..
2019-08-02 09:00:20 -04:00
2017-02-14 12:11:55 -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`