-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling Exceptions that may occur after receiving message and before processMessage() getting called. #370
Comments
Interesting, yeah this is not something that I considered as a use case and considered that failing and sending it back to the queue for reprocessing/DLQ would be enough. Some ways we could solve this is: Use a fallback annotation, like @QueueListerFallbackWe could have something like:
This is pretty clean but would involve a lot more infrastructure changes and splits up your processing between two methods. I would also want it to support other implementations like ktor so it would involve a lot more design investment so I don't believe I would get around to doing this. Provide a new payload annotation for this specific case@QueueListener(...) This is technically a lot easier and is something that you could even implement yourself! You could use the original PayloadArgumentResolver as a reference and integrate it into your spring app using this guide: Spring - How to add a custom argument resolver. If this approach works for you and you feel like committing back to this repo, I am happy to take PRs. Just let the message listener handle itThe easiest approach is to just let you handle the parsing of the POJO inside your listener, e.g. I believe you can do something like this:
obviously the negative being you have to implement your own parsing but it is the lowest effort from you side. Let me know what you think! |
Hey, Thanks for the detailed response.
While this solution seems decent. Apart from the Argument Resolver Service we may also need to consider other components where exceptions could occur after the messages are received but not yet sent to Can you think of any other situations/places where an Exception might occur and the caller would benefit by allowing it to take decision-based on it ? Let me know if I am missing something. Thanks. |
I have tried to cover all those cases so think if the message is chosen to be processed I think it would send it to the function if all the arguments can be successfully resolved. |
Thanks, So Can I pick this up ? |
Yeah that's fine if you wanted to commit it back to the repo. You can also just build it in your repo specific for your use case as well |
Hey,
First of all thanks for this awesome library.
Is there a way to handle or catch any exceptions that may occur in the library after the message is received from the queue and is not yet sent to the
processMessage()
method.Scenario:
In Spring Boot, we can use
@Payload
for de-serializing the message into Custom POJO class. Now assume that some exception occurs while de-serializing the message, in this case message will never be received toprocessMessage()
and will keep on retrying and will never get deleted from the Queue.This was just an example to explain the issue.
I am assuming that there are many such errors/exceptions that may occur after the message is successfully received by the library but is not yet sent to the
processMessage()
, is there a way to handle such exceptions and provide a custom logic of what needs to be done with such messages.Thanks.
The text was updated successfully, but these errors were encountered: