spring-projects / spring-amqp

Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ
https://spring.io/projects/spring-amqp
Apache License 2.0
809 stars 624 forks source link

Add possibility to setup and use ExceptionHandler #505

Closed asm0dey closed 7 years ago

asm0dey commented 7 years ago

As of now Spring MVC supports concept of GlobalExceptionHandler, which allows to create custom handler for any exception (and Exception class itself). In opposite spring AMQP project doesn't allow to return setup any exception handler and I must setup exception handling globally.

Typically there is 3 types of situations which involve exception handling:

  1. Potentially recoverable error. I should throw exception and message will be redelivered to me
  2. Exception in sender's logics. I should return exception to him (reply_to header or @SendTo annotation).
  3. Exception in handler's logics. Exception should be reported and message should not be redelievered.

Spring AMQP helps us to solve 1 and 3, but there is no common way to solve 2. I propose to implement one of following:

  1. Implement something like ExceptionHandler from Spring MVC.
  2. Handle throws keyword and return thrown exceptions to sender

It would be very cool if you could implement this!

garyrussell commented 7 years ago

I presume you are talking about a @RabbitListener that returns a result and have it handle (propagate) exceptions back to the client.

Spring Remoting over AMQP supports exception propagation but I agree it would be convenient if @RabbitListeners could do the same.

Please note that we track new feature requests via JIRA, not GitHub issues; I have opened a JIRA issue for this.

asm0dey commented 7 years ago

@artembilan Thank you very much! It was blazingly fast!