推送到 SQS 时的 AWS SNS 元数据
AWS SNS metadata when pushing to SQS
我正在使用 .net sdk 将消息推送到 SNS,然后 SNS 将消息发布到订阅的 SQS 队列,但 SNS 添加了消息类型等元数据,我最终得到了更大的 JSON 有效载荷,我不想,尤其是当 SQS 限制为每条消息 256k 时。
是否可以向 SNS 发送命令并告诉它不要发送该元数据?
代码如下:
var credentials = new StoredProfileAWSCredentials("dev");
using (var client = new AmazonSimpleNotificationServiceClient(credentials, Amazon.RegionEndpoint.EUWest1))
{
var request = new PublishRequest();
request.Message = message;
request.TargetArn = "ARN";
var response = client.Publish(request);
// return response;
}
这是 SNS 推送到 SQS 的内容:
{
"Type":"Notification",
"MessageId":"3333333",
"TopicArn":"ARN",
"Message": {
"Id":45,
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"Payload": {
"Internalid":"a7c50558-fc9c-47a6-b0ed-cb0cf5020f55",
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"TravelersName":"aaa aaaa",
"TravelersEmail":"aaa@aa.com",
"OwnersEmail":null,
"AccommodationId":1,
"BookingCode":"a523cd07-5506-48ad-9380-2e94002722e0"
},
"EventName":"BookingRecordCreated",
"CreatedOnUtc":"2016-09-26T15:14:55.437",
"HandledOnUtc":null
},
"Timestamp":"2016-09-26T15:14:50.923Z",
"SignatureVersion":"1",
"Signature":"dfgdfg///==",
"SigningCertURL":"https://sns",
"UnsubscribeURL":"https://sns."
}
这就是我发布到 SNS 的内容
"Message":{
"Id":45,
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"Payload": {
"Internalid":"a7c50558-fc9c-47a6-b0ed-cb0cf5020f55",
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"TravelersName":"aa aaa",
"TravelersEmail":"aa@aaa.com",
"OwnersEmail":null,
"AccommodationId":1,
"BookingCode":"a523cd07-5506-48ad-9380-2e94002722e0",
"EventName":"BookingRecordCreated",
"CreatedOnUtc":"2016-09-26T15:14:55.437",
"HandledOnUtc":null
}
}
您想在 SNS 中启用 RAW 消息传递:
http://docs.aws.amazon.com/sns/latest/dg/large-payload-raw-message.html
In addition to sending large payloads, with Amazon SNS you can now
enable raw message delivery for messages delivered to either Amazon
SQS endpoints or HTTP/S endpoints. This eliminates the need for the
endpoints to process JSON formatting, which is created for the Amazon
SNS metadata when raw message delivery is not selected. For example
when enabling raw message delivery for an Amazon SQS endpoint, the
Amazon SNS metadata is not included and the published message is
delivered to the subscribed Amazon SQS endpoint as is.
你为什么不在发布到 sns 之前压缩数据。通过它您可以发送大量数据。我相信您应该能够找到许多代码来压缩您的数据。
这是我之前用的。
Compression/Decompression string with C#
我正在使用 .net sdk 将消息推送到 SNS,然后 SNS 将消息发布到订阅的 SQS 队列,但 SNS 添加了消息类型等元数据,我最终得到了更大的 JSON 有效载荷,我不想,尤其是当 SQS 限制为每条消息 256k 时。
是否可以向 SNS 发送命令并告诉它不要发送该元数据?
代码如下:
var credentials = new StoredProfileAWSCredentials("dev");
using (var client = new AmazonSimpleNotificationServiceClient(credentials, Amazon.RegionEndpoint.EUWest1))
{
var request = new PublishRequest();
request.Message = message;
request.TargetArn = "ARN";
var response = client.Publish(request);
// return response;
}
这是 SNS 推送到 SQS 的内容:
{
"Type":"Notification",
"MessageId":"3333333",
"TopicArn":"ARN",
"Message": {
"Id":45,
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"Payload": {
"Internalid":"a7c50558-fc9c-47a6-b0ed-cb0cf5020f55",
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"TravelersName":"aaa aaaa",
"TravelersEmail":"aaa@aa.com",
"OwnersEmail":null,
"AccommodationId":1,
"BookingCode":"a523cd07-5506-48ad-9380-2e94002722e0"
},
"EventName":"BookingRecordCreated",
"CreatedOnUtc":"2016-09-26T15:14:55.437",
"HandledOnUtc":null
},
"Timestamp":"2016-09-26T15:14:50.923Z",
"SignatureVersion":"1",
"Signature":"dfgdfg///==",
"SigningCertURL":"https://sns",
"UnsubscribeURL":"https://sns."
}
这就是我发布到 SNS 的内容
"Message":{
"Id":45,
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"Payload": {
"Internalid":"a7c50558-fc9c-47a6-b0ed-cb0cf5020f55",
"MessageId":"a871f8d7-7091-4548-87c5-da3bb4131044",
"TravelersName":"aa aaa",
"TravelersEmail":"aa@aaa.com",
"OwnersEmail":null,
"AccommodationId":1,
"BookingCode":"a523cd07-5506-48ad-9380-2e94002722e0",
"EventName":"BookingRecordCreated",
"CreatedOnUtc":"2016-09-26T15:14:55.437",
"HandledOnUtc":null
}
}
您想在 SNS 中启用 RAW 消息传递:
http://docs.aws.amazon.com/sns/latest/dg/large-payload-raw-message.html
In addition to sending large payloads, with Amazon SNS you can now enable raw message delivery for messages delivered to either Amazon SQS endpoints or HTTP/S endpoints. This eliminates the need for the endpoints to process JSON formatting, which is created for the Amazon SNS metadata when raw message delivery is not selected. For example when enabling raw message delivery for an Amazon SQS endpoint, the Amazon SNS metadata is not included and the published message is delivered to the subscribed Amazon SQS endpoint as is.
你为什么不在发布到 sns 之前压缩数据。通过它您可以发送大量数据。我相信您应该能够找到许多代码来压缩您的数据。
这是我之前用的。 Compression/Decompression string with C#