0

How can we confirm the subscription request from Amazon SNS using spring-boot and spring-cloud-starter-aws-messaging?

According to the Spring Cloud AWS – Messaging Support tutorial we need to add the topic name to the @RequestMapping annotation on the controller level.

And then in the SNS subscription we add the end-point like this: http://foo.eu-west-1.elb.amazonaws.com/topic_name-sns

=> But in my case the subscription is never confirmed and I don't know why.

Here's the piece of code I am using:

@Controller
@RequestMapping("/topic_name-sns")
public class SNSEndpointController {

    private static final Logger logger = LoggerFactory.getLogger(SNSEndpointController.class);

    @NotificationMessageMapping
    public void receiveNotification(@NotificationMessage String message, @NotificationSubject String subject) {
        logger.info("Received message: {}, having subject: {}", message, subject);
    }

    @NotificationUnsubscribeConfirmationMapping
    public void confirmSubscriptionMessage(NotificationStatus notificationStatus) {
        logger.info("Unsubscribed from Topic");
        notificationStatus.confirmSubscription();
    }

    @NotificationSubscriptionMapping
    public void confirmUnsubscribeMessage(NotificationStatus notificationStatus) {
        logger.info("Subscribed to Topic");
        notificationStatus.confirmSubscription();
    }
}
cs4r
  • 584
  • 6
  • 15

2 Answers2

0

TO work with Spring Framework and the SNS Service, consider using the official AWS SDK for Java V2 as discussed in this AWS tutorial.

Creating a Publish/Subscription Spring Boot Application

As discussed, you can easily use the AWS SDK for Java API within a Spring project and there is no need to use a 3rd party API over an AWS API. By doing so, you will have support from the AWS SDK team. If you continue to use a 3rd party API, you do not have support from the AWS SDK team.

smac2020
  • 9,637
  • 4
  • 24
  • 38
0

At the end I found the issue. It was related to permissions, my ECS task didn't have permissions to confirm subscriptions that's why the subscription was never confirmed.

cs4r
  • 584
  • 6
  • 15