awspring / spring-cloud-aws

The New Home for Spring Cloud AWS
http://awspring.io
Apache License 2.0
878 stars 299 forks source link

Support for SnsTemplate with SnsAsyncClient #687

Open bergac opened 1 year ago

bergac commented 1 year ago

Type: Feature

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like The feature would be in the spring-cloud-aws-sns project. It would be nice if support for the SnsAsyncClient in a form of a helper class like SnsTemplate is provided. Like the NotificationMessagingTemplate in version 2.x.

Describe alternatives you've considered Write the class myself.

Additional context Nothing...

maciejwalkowiak commented 1 year ago

@bergac could you please sketch the API you have in mind?

bergac commented 1 year ago

Same as SnsTemplate but with the SnsAsyncClient instead of SnsClient.

maciejwalkowiak commented 1 year ago

@bergac feel free to drop a PR. We will tackle async apis eventually in 3.x and this will be a good starting point.

artembilan commented 1 year ago

Plus one from Spring Integration AWS. Our SnsMessageHandler is based on the SnsAsyncClient and I realized that I need to use a DefaultTopicArnResolver which is based on an SnsClient. Sure! I can create a new one based on SnsAsyncClient myself, but an auto-configuration from SC-AWS still exposes only an SnsClient. Thank you!

myrabetty commented 1 year ago

@maciejwalkowiak Hello. I looked a bit into the the issue. I found that there are two places where the async processing needs to be introduced in the current flow when using the SnsAsynClient: one when subscribing to the topic, and one when sending messages. The first can be easily modified as it calls directly the aws cdk. The other used to send a message is based on an implementation on top of the AbstractMessageChannel which comes from spring-messaging and has no concept of async, therefore one must choose an alternative. So far, I decided to duplicate that class (the send method which does all the job final so I did not find a way around it) and modify as needed, but maybe there are other ways or maybe it is better to use some other library? I commited what I did in a separate in a fork, it is not complete but the functionality is implemented. In case you think this is worth pursuing and/or have suggestions I can work on it and create a PR.

maciejwalkowiak commented 1 year ago

@myrabetty i think it is going in the right direction but we need to think how can we do it without duplicating so much code. Maybe @MatejNedic can chime in and have a deeper look at it.

MatejNedic commented 1 year ago

Hey, I will check this in more detail once 3.0.0 is out.

syedyusufh commented 2 weeks ago

@MatejNedic / @maciejwalkowiak kindly, any update on this feature request? Looking for SnsTemplate backed by SnsAsyncClient.

maciejwalkowiak commented 2 weeks ago

No update yet. Most likely in the next release we will auto-configure async clients and this will be a good start to add async counterparts for other integrations.