spring-cloud-aws
spring-cloud-aws copied to clipboard
Add `NotificationRequestConverter` and `NotificationMessageArgumentResolver` to allow reading SNS messages on SQS
:loudspeaker: Type of change
- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
:scroll: Description
#887
:bulb: Motivation and Context
It allows for reading an SNS Message on an SQS Queue by using @NotficationMessage
:green_heart: How did you test it?
Manually(will try to add tests when I have time)
:pencil: Checklist
- [ ] I reviewed submitted code
- [ ] I added tests to verify changes
- [ ] I updated reference documentation to reflect the change
- [x] All tests passing
- [x] No breaking changes
:crystal_ball: Next steps
@tomazfernandes This is more of a draft for now, this works locally for me but was unsure where these files truly belong. I have put then in the sns project for now, since they use @NotificationMessage which lives there, and didn't want SQS project to have a dependency on the SNS one.
Let me know if you agree, or we should create a new annotation to be used.
Also in the previous implementation of NotificationRequestConverter it added MessageAttributes to the message. For my use-case I was able to remove that completely and things worked fine. Let me know if that is actually needed, but I did see SqsHeaderMapper has a lot of the same logic for what was being done for MessageAttributes
Hi @msosa, thanks for the PR.
I'm leaning towards having a separate annotation, since the modules are now separated, and I believe it would make sense for a project to consume an SNS message from SQS but not need anything from the SNS module itself.
We'd probably want to have a different name for the annotation so that it's not confusing for the users.
@MatejNedic, do you have any thoughts on this? Anything I might be missing regarding the integration between the modules?
Thanks
Makes sense, I have moved all the code into SQS and created a new annotation called SnsNotificationMessage(open to alternative names).
Hi, I just saw your merge request. I am currently working around this missing feature, since we want to update to spring boot 3. And I wonder if the MessageAttributes from the SNS notification don't need to be mapped into MessageHeader as well? Best regards, Johannes
Hello @msosa ,
Do you have plans to further work on this MR?
I have implemented something internally very similarly and would love to drop this code in favor of the opensource implementation.
The main difference was related to the MessageConverter. In our case we do use CloudEvents and the current MessageConverter is not able to handle well subtypes likes CloudEvent<MyEvent>. It is a super tiny change but that enables a lot. I would be more than happy to create a mr to your branch if you wish.
HI @gustavomonarin,
Yes I do plan on working on this MR, was just waiting for review(I just realized I may not have requested said review)
But yeah am open to checking out and change you mentioned and bringing into this MR
Hey @msosa, really sorry for the delay - I thought I was the one waiting for your reply. Left a few comments on the PR, please let me know if they make sense to you.
@gustavomonarin thanks for showing up. Can you share a bit more about what's your proposed change?
Thanks.
current MessageConverter is not able to handle well subtypes likes CloudEvent<MyEvent>
@gustavomonarin, can you elaborate on this please?
Hi @msosa and @tomazfernandes i mad a small change in the test to cover the case i mentioned.
Also provided two implementation solutions, a small one in the spring way of compatibility and a second one with a bit more ofbreaking change on the bean post processor.
The PR has not much deatils in the description but the two commit messages goes in the details, so i would suggest to review the commits individually.
Hi @msosa and @tomazfernandes i mad a small change in the test to cover the case i mentioned.
Also provided two implementation solutions, a small one in the spring way of compatibility and a second one with a bit more ofbreaking change on the bean post processor.
The PR has not much deatils in the description but the two commit messages goes in the details, so i would suggest to review the commits individually.
@gustavomonarin I don't see your PR with these commits, where can I find it?
@msosa we're pretty much there!
The only thing missing is the documentation, let me know if you need any help with that.
Thanks!
Hi @msosa and @tomazfernandes i mad a small change in the test to cover the case i mentioned.
Also provided two implementation solutions, a small one in the spring way of compatibility and a second one with a bit more ofbreaking change on the bean post processor.
The PR has not much deatils in the description but the two commit messages goes in the details, so i would suggest to review the commits individually.
@gustavomonarin I don't see your PR with these commits, where can I find it?
It is on the @msosa original repo, as is based on his changes.
@tomazfernandes Awesome, appreciate all the feedback!
I gave the documentation a try, let me know what you think.
@gustavomonarin, I looked at your suggestion to switch from implementing the MessageConverter interface to implementing the SmartMessageConverter interface which allows type hints and it makes sense.
I prefer the solution in this PR as it allows more flexibility for the user and is not a breaking change.
Now, not sure how to coordinate this - we do have an eminent version release coming up and it'd be great to have this feature in it.
@msosa, how would you feel about incorporating @gustavomonarin's changes into your PR?
@tomazfernandes of course, I have merged your preferred solution of @gustavomonarin into this PR.
Also I have updated the the documentation section to talk about SNS Messages
Removed the Note @tomazfernandes, let me know if there's anything else
@tomazfernandes Done! I just used @gustavomonarin username as I wasn't sure if exact first/last name.
@tomazfernandes Done! I just used @gustavomonarin username as I wasn't sure if exact first/last name.
Thanks @msosa!
@gustavomonarin, please let us know if you want us to name you in any other way.
Looks great for Single Message processing. What is your recommendation to receive a List of SNSNotificationMessages for batch processing?
We are also looking for a way to receive a List of SnsNotificationMessages and struggling with this. Any suggestions?