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();
}
}