简体   繁体   English

将AWS S3事件转发到SQS最终会变成与从S3到SNS到SQS不同的消息吗?

[英]Will AWS S3 event forwarding to SQS will end up being a different message than S3 to SNS to SQS?

I am using a Splunk Technical Add-on that will be pulling messages from an SQS queue. 我正在使用Splunk技术插件,该插件将从SQS队列中提取消息。 Although the TA suggests using S3 forwarding to an SNS and it subscribed to an SQS, there is also the possibility of S3 to forward directly to SQS. 尽管TA建议使用S3转发到SNS并订阅了SQS,但是S3也有可能直接转发到SQS。

Would SNS make any change on what S3 send to it? SNS会对S3发送的内容进行任何更改吗? Or would it be a fully transparent transport method to SQS? 还是对SQS完全透明的传输方法?

Yes, by default, S3 → SQS and S3 → SNS → SQS will result in two different data structures/formats inside the SQS message body. 是的,默认情况下,S3→SQS和S3→SNS→SQS将在SQS消息主体内产生两种不同的数据结构/格式。

This is because an SNS subscription provides metadata with each message delivered -- the SNS MessageId , a Signature to validate authenticity, a Timestamp of when SNS originally accepted the message, and other attributes. 这是因为SNS订阅会为每个传递的消息提供元数据 -SNS MessageId ,验证真实性的Signature ,SNS最初接受消息的Timestamp和其他属性。 The original message is encoded as a JSON string inside the Message attribute of this outer JSON structure. 原始消息在此外部JSON结构的Message属性内被编码为JSON字符串。

So with SQS direct, you would extract the S3 event with (pseudocode)... 因此,使用直接SQS,您可以使用(伪代码)提取S3事件...

s3event = JSON.parse(sqsbody)

...but with SNS to SQS... ...但是从SNS到SQS ...

s3event = JSON.parse(JSON.parse(sqsbody).Message)

You can disable the additional structures and have SNS send only the original payload by enabling raw message delivery on the SQS subscription to the SNS topic. 您可以禁用其他结构,并通过对SNS主题的SQS订阅启用原始消息传递来使SNS仅发送原始有效负载。

https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html

With raw message delivery enabled, the contents become the same, for both S3 → SQS and S3 → SNS → SQS. 启用原始消息传递后,S3→SQS和S3→SNS→SQS的内容将相同。

The downside to raw message delivery is that you lose potentially useful troubleshooting information with raw message delivery, like the SNS message ID and SNS-issued timestamp. 原始消息传递的不利之处在于,原始消息传递会丢失潜在有用的故障排除信息,例如SNS消息ID和SNS发出的时间戳。

On the other hand, if the receiving service (the SQS consumer) assumes the messages are always coming via SNS and expects to find the SNS data structure in the SQS message body, then sending direct S3 → SQS will result in the consumer finding that the message body from SQS does not match its expectations. 另一方面,如果接收服务(SQS使用者)假定消息总是通过SNS来发送,并希望在SQS消息正文中找到SNS数据结构,则直接发送S3→SQS将导致使用者发现SQS的邮件正文与预期不符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM