Skip to content

Add SQS module @SnsNotificationMessage batch messages support #1133

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

Closed
wants to merge 1 commit into from

Conversation

maxjiang153
Copy link
Contributor

@maxjiang153 maxjiang153 commented Apr 6, 2024

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

see: #1129

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

@github-actions github-actions bot added the component: sqs SQS integration related issue label Apr 6, 2024
@maxjiang153 maxjiang153 force-pushed the gh-1129 branch 3 times, most recently from 09ca31f to d1cdf70 Compare April 7, 2024 00:37
Copy link
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks great @wmz7year, thanks!

Would you mind adding an entry in the docs for it?

Thanks!

@github-actions github-actions bot added the type: documentation Documentation or Samples related issue label Apr 15, 2024
@maxjiang153
Copy link
Contributor Author

maxjiang153 commented Apr 15, 2024

@tomazfernandes I've added the doc description for this, please check it out. And if everything is okay, I'll rebase it into a single commit.

Copy link
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with the docs @wmz7year! Just a couple of nits and we should be ready to go.


The @SnsNotificationMessage annotation can be used for both single and batch message processing.

For single message processing, you can use the @SnsNotificationMessage annotation as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We avoid using you and and use a more formal tone instead.

So maybe something like the @SnsNotificationMessage annotation can be used as follows:?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -626,6 +631,16 @@ public void listen(@SnsNotificationMessage Pojo pojo) {
}
----

For batch message processing, you can use the @SnsNotificationMessage annotation with a List<Pojo> parameter:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here about using you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, check it out again plz.

Copy link
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @maxjiang153!

Looks good overall, left a couple of questions.

* SNS Message wrapper.
*/
public record SnsMessageWrapper(String subject, Object message) {
static Type getResolvedType(Class<?> targetClass, @Nullable Object conversionHint) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this static and not private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -77,7 +105,7 @@ public Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Ob
? ((SmartMessageConverter) this.payloadConverter).fromMessage(genericMessage, targetClass,
conversionHint)
: this.payloadConverter.fromMessage(genericMessage, targetClass);
return new SnsMessageWrapper(jsonNode.path("Subject").asText(), convertedMessage);
return convertedMessage;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the Wrapper?

While I understand we're not currently using the subject, I think it might be helpful if we eventually want to allow retrieving it.

Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is because when NotificationMessageArgumentResolver tries to resolving the messages, it might be a single message or a message list. So it will be more tricky to keep the wrapper when processing this situation.

So that's the reason I removed the wrapper.

@tomazfernandes
Copy link
Contributor

Hey @maxjiang153, just a ping here to maybe try to merge this before the next version is out. Thanks!

@maxjiang153
Copy link
Contributor Author

@tomazfernandes Hi, sorry for the late response. I was busy with other stuff. I've already updated this PR and check it again pls.

@tomazfernandes
Copy link
Contributor

Same thing here @maxjiang153, I added some polishing to this PR to expedite merging: #1191

Thanks again for the PR and looking forward to more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue type: documentation Documentation or Samples related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants