如何使用 Java SDK 以编程方式删除已确认的 SNS 订阅(但不是主题)?
How to programmatically delete confirmed SNS subscription (but not the topic) using Java SDK?
我正在编写一个应用程序,它以编程方式创建一个订阅现有 SNS 主题的新 SQS 队列,然后删除该 SQS 队列。
我知道有一种方法可以使用 Java SDK 删除 SNS 主题及其订阅。我知道我可以从 Web 控制台手动删除已确认的订阅。我知道待定订阅会自行过期。
但我想以编程方式删除已确认的订阅,但保留 SNS 主题。或者我确认的订阅会在 SQS 队列消失一段时间后过期吗?
要使用 Java SDK 删除 Amazon SNS 主题的订阅者,您应该使用 unsubscribe()
命令。
default UnsubscribeResponse unsubscribe(Consumer<UnsubscribeRequest.Builder> unsubscribeRequest)
throws InvalidParameterException,
InternalErrorException,
AuthorizationErrorException,
NotFoundException,
InvalidSecurityException,
AwsServiceException,
SdkClientException,
SnsException
Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the Unsubscribe call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe request was unintended.
我正在编写一个应用程序,它以编程方式创建一个订阅现有 SNS 主题的新 SQS 队列,然后删除该 SQS 队列。
我知道有一种方法可以使用 Java SDK 删除 SNS 主题及其订阅。我知道我可以从 Web 控制台手动删除已确认的订阅。我知道待定订阅会自行过期。
但我想以编程方式删除已确认的订阅,但保留 SNS 主题。或者我确认的订阅会在 SQS 队列消失一段时间后过期吗?
要使用 Java SDK 删除 Amazon SNS 主题的订阅者,您应该使用 unsubscribe()
命令。
default UnsubscribeResponse unsubscribe(Consumer<UnsubscribeRequest.Builder> unsubscribeRequest)
throws InvalidParameterException,
InternalErrorException,
AuthorizationErrorException,
NotFoundException,
InvalidSecurityException,
AwsServiceException,
SdkClientException,
SnsException
Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the Unsubscribe call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe request was unintended.