本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
SetSubscriptionAttributesRedrivePolicy
搭配 使用 AWS SDK
下列程式碼範例示範如何使用 SetSubscriptionAttributesRedrivePolicy
。
- Java
-
- SDK 適用於 Java 1.x
-
// Specify the ARN of the Amazon SNS subscription.
String subscriptionArn =
"arn:aws:sns:us-east-2:123456789012:MyEndpoint:1234a567-bc89-012d-3e45-6fg7h890123i";
// Specify the ARN of the Amazon SQS queue to use as a dead-letter queue.
String redrivePolicy =
"{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-2:123456789012:MyDeadLetterQueue\"}";
// Set the specified Amazon SQS queue as a dead-letter queue
// of the specified Amazon SNS subscription by setting the RedrivePolicy attribute.
SetSubscriptionAttributesRequest request = new SetSubscriptionAttributesRequest()
.withSubscriptionArn(subscriptionArn)
.withAttributeName("RedrivePolicy")
.withAttributeValue(redrivePolicy);
sns.setSubscriptionAttributes(request);
如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 SNS 搭配 使用 Amazon AWS SDK。本主題也包含有關入門的資訊,以及先前SDK版本的詳細資訊。