Documentation: How to configure SnsMessageHandler
chrylis opened this issue · 3 comments
The documentation here provides an example of configuring SnsMessageHandler
using a bean amazonSns()
that is not defined inside the snippet. As of 2.4.2, Spring Integration AWS appears to require an AmazonSNSAsync
instance rather than simply an AmazonSNS
instance. While this matches the AmazonSQSAsync
in the SQS inbound adapter, AWSpring (confusingly) auto-configures an SQS bean that implements AmazonSQSAsync
but an SNS bean that does not implement AmazonSNSAsync
.
What's the best way to get the SNS outbound adapter configured? Do I have to manually register the AmazonSNSAsync
bean?
Not sure why is the question: how you configure an AmazonSNSAsync
is out of this project scope.
The fact that we use some API from Spring Cloud AWS doesn't mean that something is really has to be auto-configured for us.
Yes, for better end-user experience Spring Cloud AWS must auto-configure an AmazonSNSAsync
instead of plain one as you state in that linked issue.
But again: nothing what we have to do in this project.
You probably can just do whatever is there in the auto-configuration:
@Bean
public AmazonWebserviceClientFactoryBean<AmazonSNSAsyncClient> amazonSNS(SnsProperties properties,
AWSCredentialsProvider awsCredentialsProvider,
RegionProvider regionProvider,
) {
AmazonWebserviceClientFactoryBean<AmazonSNSAsyncClient> clientFactoryBean = new AmazonWebserviceClientFactoryBean<>(
AmazonSNSAsyncClient.class, awsCredentialsProvider, regionProvider, null);
Optional.ofNullable(properties.getEndpoint()).ifPresent(clientFactoryBean::setCustomEndpoint);
return clientFactoryBean;
}
or so.
See more info here: https://github.com/awspring/spring-cloud-aws/blob/2.4.x/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/messaging/SnsAutoConfiguration.java
From my perspective, it is worth noting this in the documentation here, at least unless the auto-config in AWSpring is updated. It's very surprising to start working with an inbound adapter that works out of the box and then have the outbound adapter require reconfiguration.
As you said: it is worth nothing for SC AWSpring to update their auto-configuration: public interface AmazonSNSAsync extends AmazonSNS {
. So, everything is going to be OK, even if you expect somewhere sync client instead of async.