메시지 형식 구문 분석 - Amazon Simple Notification Service

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

메시지 형식 구문 분석

Amazon SNS는 다음의 형식을 사용합니다.

HTTP/HTTPS 헤더

Amazon SNS가 구독 확인, 알림 또는 구독 해지 확인 메시지를 HTTP/HTTPS 엔드포인트에 전송할 때 Amazon SNS에 특정한 여러 헤더 값과 함께 POST 메시지를 전송합니다. 이러한 작업의 헤더 값을 사용하면 Type 값을 읽기 위해 JSON 메시지 본문을 구문 분석할 필요 없이 메시지 유형을 파악할 수 있습니다. 기본적으로 Amazon SNS는 text/plain; charset=UTF-8로 설정된 Content-Type로 모든 알림을 HTTP/S 엔드포인트로 전송합니다. 텍스트/일반(기본값) 외 Content-Type을 선택하려면 HTTP/S 전송 정책 생성headerContentType를 참조하세요.

x-amz-sns-message-type

메시지의 유형입니다. 가능한 값은 SubscriptionConfirmation, NotificationUnsubscribeConfirmation 입니다.

x-amz-sns-message-id

범용 고유 식별자(UUID)로 게시되는 각 메시지마다 고유합니다. 재시도 중에 Amazon SNS가 재전송하는 알림의 경우 원본 메시지의 메시지 ID가 사용됩니다.

x-amz-sns-topic-arn

이 메시지가 게시된 주제에 대한 Amazon Resource Name(ARN)입니다.

x-amz-sns-subscription-arn

이 엔드포인트에 대한 구독의 ARN입니다.

다음의 HTTP POST 헤더는 HTTP 엔드포인트에 대한 Notification 메시지 헤더의 예입니다.

POST / HTTP/1.1 x-amz-sns-message-type: Notification x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic x-amz-sns-subscription-arn: arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55 Content-Length: 1336 Content-Type: text/plain; charset=UTF-8 Host: myhost.example.com Connection: Keep-Alive User-Agent: Amazon Simple Notification Service Agent

HTTP/HTTPS 구독 확인 JSON 형식

사용자가 HTTP/HTTPS 엔드포인트를 구독한 후에 Amazon SNS는 구독 확인 메시지를 HTTP/HTTPS 엔드포인트에 전송합니다. 이 메시지는 구독을 확인하기 위해 방문해야 하는 SubscribeURL 값을 담고 있습니다(또는, Token 값을 ConfirmSubscription과 함께 사용할 수 있습니다).

참고

Amazon SNS는 구독이 확인되기 전에는 알림을 이 엔드포인트로 전송하지 않습니다.

구독 확인 메시지는 다음의 이름/값 쌍을 갖는 JSON 문서를 포함하는 메시지 본문으로 된 POST 메시지입니다.

Type

메시지의 유형입니다. 구독 확인의 경우 유형은 SubscriptionConfirmation입니다.

MessageId

범용 고유 식별자(UUID)로 게시되는 각 메시지마다 고유합니다. 재시도 중에 Amazon SNS가 재전송하는 메시지의 경우 원본 메시지의 메시지 ID가 사용됩니다.

Token

구독 확인을 위해 ConfirmSubscription 작업에 사용할 수 있는 값입니다. 또는, 간단히 SubscribeURL을 방문하면 됩니다.

TopicArn

이 메시지가 구독된 주제에 대한 Amazon Resource Name(ARN)입니다.

Message

메시지를 설명하는 문자열입니다. 구독 확인의 경우 이 문자열은 다음과 같습니다.

You have chosen to subscribe to the topic arn:aws:sns:us-east-2:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.
SubscribeURL

구독 확인을 위해 방문해야 하는 URL입니다. 또는 TokenConfirmSubscription 작업으로 사용하여 구독을 확인하면 됩니다.

Timestamp

구독 확인이 전송된 시간(GMT)입니다.

SignatureVersion

사용한 Amazon SNS 서명의 버전입니다.

  • SignatureVersion1인 경우, Signature는, Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA1withRSA 서명입니다.

  • SignatureVersion2인 경우, Signature는, Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA256withRSA 서명입니다.

Signature

Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA1withRSA 또는 SHA256withRSA 서명입니다.

SigningCertURL

메시지에 서명하기 위해 사용된 인증서의 URL입니다.

다음의 HTTP POST 메시지는 HTTP 엔드포인트에 대한 SubscriptionConfirmation 메시지의 예입니다.

POST / HTTP/1.1 x-amz-sns-message-type: SubscriptionConfirmation x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic Content-Length: 1336 Content-Type: text/plain; charset=UTF-8 Host: myhost.example.com Connection: Keep-Alive User-Agent: Amazon Simple Notification Service Agent { "Type" : "SubscriptionConfirmation", "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b", "Token" : "2336412f37...", "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic", "Message" : "You have chosen to subscribe to the topic arn:aws:sns:us-west-2:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.", "SubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=2336412f37...", "Timestamp" : "2012-04-26T20:45:04.751Z", "SignatureVersion" : "1", "Signature" : "EXAMPLEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=", "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem" }

HTTP/HTTPS 알림 JSON 형식

Amazon SNS가 구독된 HTTP 또는 HTTPS 엔드포인트에 알림을 전송할 때 엔드포인트에 전송된 POST 메시지는 다음의 이름/값 쌍으로 된 JSON 문서를 구성하는 메시지 본문을 보유합니다.

Type

메시지의 유형입니다. 알림의 경우 유형은 Notification입니다.

MessageId

범용 고유 식별자(UUID)로 게시되는 각 메시지마다 고유합니다. 재시도 중에 Amazon SNS가 재전송하는 알림의 경우 원본 메시지의 메시지 ID가 사용됩니다.

TopicArn

이 메시지가 게시된 주제에 대한 Amazon Resource Name(ARN)입니다.

Subject

알림이 주제에 게시되었을 때 Subject 매개 변수입니다.

참고

이는 선택 가능한 파라미터입니다. Subject이 지정되지 않을 경우에는 이 이름-값 쌍은 본 JSON 문서에 표시되지 않습니다.

Message

알림이 주제에 게시되었을 때 지정되는 Message 값입니다.

Timestamp

알림이 게시된 시간(GMT)입니다.

SignatureVersion

사용한 Amazon SNS 서명의 버전입니다.

  • SignatureVersion1인 경우, SignatureMessage, MessageId, Subject(있는 경우), Type, Timestamp, TopicArn 값의 Base64로 인코딩된 SHA1withRSA 서명입니다.

  • SignatureVersion2인 경우, SignatureMessage, MessageId, Subject(있는 경우), Type, Timestamp, TopicArn 값의 Base64로 인코딩된 SHA256withRSA 서명입니다.

Signature

Message, MessageId, Subject(있는 경우), Type, Timestamp, TopicArn 값의 Base64로 인코딩된 SHA1withRSA 또는 SHA256withRSA 서명입니다.

SigningCertURL

메시지에 서명하기 위해 사용된 인증서의 URL입니다.

UnsubscribeURL

이 주제에서 엔드포인트를 구독 해지하는데 사용하는 URL입니다. 이 URL을 방문하면 Amazon SNS는 엔드포인트를 구독 해지하고 이 엔드포인트로 전송하는 알림을 중지합니다.

다음의 HTTP POST 메시지는 HTTP 엔드포인트에 대한 Notification 메시지의 예입니다.

POST / HTTP/1.1 x-amz-sns-message-type: Notification x-amz-sns-message-id: 22b80b92-fdea-4c2c-8f9d-bdfb0c7bf324 x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic x-amz-sns-subscription-arn: arn:aws:sns:us-west-2:123456789012:MyTopic:c9135db0-26c4-47ec-8998-413945fb5a96 Content-Length: 773 Content-Type: text/plain; charset=UTF-8 Host: myhost.example.com Connection: Keep-Alive User-Agent: Amazon Simple Notification Service Agent { "Type" : "Notification", "MessageId" : "22b80b92-fdea-4c2c-8f9d-bdfb0c7bf324", "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic", "Subject" : "My First Message", "Message" : "Hello world!", "Timestamp" : "2012-05-02T00:54:06.655Z", "SignatureVersion" : "1", "Signature" : "EXAMPLEw6JRN...", "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem", "UnsubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:c9135db0-26c4-47ec-8998-413945fb5a96" } }

HTTP/HTTPS 구독 해지 확인 JSON 형식

주제에서 HTTP/HTTPS 엔드포인트가 구독 해지된 후 Amazon SNS는 엔드포인트에 구독 해지 확인 메시지를 전송합니다.

구독 해지 확인 메시지는 다음의 이름/값 쌍을 갖는 JSON 문서를 포함하는 메시지 본문으로 된 POST 메시지입니다.

Type

메시지의 유형입니다. 구독 해지 확인의 경우 유형은 UnsubscribeConfirmation입니다.

MessageId

범용 고유 식별자(UUID)로 게시되는 각 메시지마다 고유합니다. 재시도 중에 Amazon SNS가 재전송하는 메시지의 경우 원본 메시지의 메시지 ID가 사용됩니다.

Token

구독 재확인을 위해 ConfirmSubscription 작업에 사용할 수 있는 값입니다. 또는, 간단히 SubscribeURL을 방문하면 됩니다.

TopicArn

이 엔드포인트가 구독 해지된 주제에 대한 Amazon Resource Name(ARN)입니다.

Message

메시지를 설명하는 문자열입니다. 구독 해지 확인의 경우 이 문자열은 다음과 같습니다.

You have chosen to deactivate subscription arn:aws:sns:us-east-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55.\nTo cancel this operation and restore the subscription, visit the SubscribeURL included in this message.
SubscribeURL

구독 재확인을 위해 방문해야 하는 URL입니다. 또는, 그 대신 TokenConfirmSubscription 작업으로 사용하여 구독을 재확인하면 됩니다.

Timestamp

구독 해지 확인이 전송된 시간(GMT)입니다.

SignatureVersion

사용한 Amazon SNS 서명의 버전입니다.

  • SignatureVersion1인 경우, Signature는, Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA1withRSA 서명입니다.

  • SignatureVersion2인 경우, Signature는, Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA256withRSA 서명입니다.

Signature

Message, MessageId, Type, Timestamp, 및 TopicArn 값의 Base64로 인코딩된 SHA1withRSA 또는 SHA256withRSA 서명입니다.

SigningCertURL

메시지에 서명하기 위해 사용된 인증서의 URL입니다.

다음의 HTTP POST 메시지는 HTTP 엔드포인트에 대한 UnsubscribeConfirmation 메시지의 예입니다.

POST / HTTP/1.1 x-amz-sns-message-type: UnsubscribeConfirmation x-amz-sns-message-id: 47138184-6831-46b8-8f7c-afc488602d7d x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic x-amz-sns-subscription-arn: arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55 Content-Length: 1399 Content-Type: text/plain; charset=UTF-8 Host: myhost.example.com Connection: Keep-Alive User-Agent: Amazon Simple Notification Service Agent { "Type" : "UnsubscribeConfirmation", "MessageId" : "47138184-6831-46b8-8f7c-afc488602d7d", "Token" : "2336412f37...", "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic", "Message" : "You have chosen to deactivate subscription arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55.\nTo cancel this operation and restore the subscription, visit the SubscribeURL included in this message.", "SubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=2336412f37fb6...", "Timestamp" : "2012-04-26T20:06:41.581Z", "SignatureVersion" : "1", "Signature" : "EXAMPLEHXgJm...", "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem" }

SetSubscriptionAttributes 전송 정책 JSON 형식

SetSubscriptionAttributes 작업에 요청을 전송하고 DeliveryPolicy의 값에 대해 AttributeName 매개 변수를 설정할 경우, AttributeValue 매개 변수의 값은 유효한 JSON 객체이어야 합니다. 예를 들어, 다음의 예는 최대 5회 재시도하도록 전송 정책을 설정합니다.

http://sns.us-east-2.amazonaws.com/ ?Action=SetSubscriptionAttributes &SubscriptionArn=arn%3Aaws%3Asns%3Aus-east-2%3A123456789012%3AMy-Topic%3A80289ba6-0fd4-4079-afb4-ce8c8260f0ca &AttributeName=DeliveryPolicy &AttributeValue={"healthyRetryPolicy":{"numRetries":5}} ...

AttributeValue 매개 변수의 값에 다음의 JSON 형식을 사용합니다.

{ "healthyRetryPolicy" : { "minDelayTarget" : int, "maxDelayTarget" : int, "numRetries" : int, "numMaxDelayRetries" : int, "backoffFunction" : "linear|arithmetic|geometric|exponential" }, "throttlePolicy" : { "maxReceivesPerSecond" : int }, "requestPolicy" : { "headerContentType" : "text/plain | application/json | application/xml" } }

SetSubscriptionAttribute 작업에 대한 자세한 내용을 확인하려면 Amazon Simple Notification Service API 참조SetTopicAttributes로 이동하세요. 지원되는 HTTP 콘텐츠 유형 헤더에 대한 자세한 내용은 HTTP/S 전송 정책 생성을 참조하세요.

SetTopicAttributes 전송 정책 JSON 형식

SetTopicAttributes 작업에 요청을 전송하고 DeliveryPolicy의 값에 대해 AttributeName 매개 변수를 설정할 경우, AttributeValue 매개 변수의 값은 유효한 JSON 객체이어야 합니다. 예를 들어, 다음의 예는 최대 5회 재시도하도록 전송 정책을 설정합니다.

http://sns.us-east-2.amazonaws.com/ ?Action=SetTopicAttributes &TopicArn=arn%3Aaws%3Asns%3Aus-east-2%3A123456789012%3AMy-Topic &AttributeName=DeliveryPolicy &AttributeValue={"http":{"defaultHealthyRetryPolicy":{"numRetries":5}}} ...

AttributeValue 매개 변수의 값에 다음의 JSON 형식을 사용합니다.

{ "http" : { "defaultHealthyRetryPolicy" : { "minDelayTarget": int, "maxDelayTarget": int, "numRetries": int, "numMaxDelayRetries": int, "backoffFunction": "linear|arithmetic|geometric|exponential" }, "disableSubscriptionOverrides" : Boolean, "defaultThrottlePolicy" : { "maxReceivesPerSecond" : int }, "defaultRequestPolicy" : { "headerContentType" : "text/plain | application/json | application/xml" } } }

SetTopicAttribute 작업에 대한 자세한 내용을 확인하려면 Amazon Simple Notification Service API 참조SetTopicAttributes로 이동하세요. 지원되는 HTTP 콘텐츠 유형 헤더에 대한 자세한 내용은 HTTP/S 전송 정책 생성을 참조하세요.