micronaut-projects / micronaut-jms

Integration between Micronaut and JMS
Apache License 2.0
14 stars 14 forks source link

Implement exception handlers for @JMSListener #37

Closed elliottpope closed 1 year ago

elliottpope commented 3 years ago

Task List

Steps to Reproduce

  1. Create an @JMSListener that throws an exception i.e.
    @JMSListener("activeMqConnectionFactory")
    public class MessageListener {
    @Queue(value = "test", concurrency = "1-1")
    public void receive(@Body String message) {
        throw new RuntimeException("This is a loud exception!!");
    }
    }
  2. Consume a message from the queue

Expected Behaviour

  1. If no configuration is provided, then the exception should be logged at the ERROR level
  2. Allow the developer to provide a custom error handler using an errorHandler annotation parameter
  3. Allow the developer to provide a global custom error handler using a JMSErrorHandler

Actual Behaviour

The method aborts without any log messages or a stack trace

Environment Information

Example Application

drmaciej commented 3 years ago

That would be good to have, I myself spent a little time troubleshooting before I realised I had a problem and the exception was swalllowed.

elliottpope commented 3 years ago

@drmaciej thanks for trying the library out, feel free to add any other issues you find. I'm currently working on a PR for this (closed by #54) so once that's merged we should be able to do a second milestone release

drmaciej commented 3 years ago

Thanks @elliottpope, I'm looking forward to the next release.

Just to clarify on this issue - the problem I had related to inability to bind to listener's parameters in AbstractJMSListenerMethodProcessor#generateAndBindListener at binder.bind(...). This exception was swallowed, whereas it should have been logged. Hopefully your fix addresses exceptions both in the "plumbing" and listeners themselves.

Actually, one more issue/concern/wonderment has come to mind, so I'll create a separate issue.

elliottpope commented 3 years ago

@drmaciej yes, I have observed this issue too and the solution will address both and I'll ensure there are test cases to cover both scenarios

drmaciej commented 3 years ago

@elliottpope sounds great, thanks!

drmaciej commented 3 years ago

Hi @elliottpope, Good to see 1.0.0.M2! I'll definitely give it a try. Otherwise, we've been quite happy with M1, no major complaints, but we're just wondering when the exception handler might make it into a release. Would you be able to shed some light?

graemerocher commented 1 year ago

Fixed in https://github.com/micronaut-projects/micronaut-jms/commits/master