消息 -> sqs 与消息 -> sns -> sqs
Message -> sqs vs Message -> sns -> sqs
我有一个任务生成器来向 SQS 队列生成任务消息,还有一群工作人员轮询 SQS 队列来处理任务。在这种情况下,让任务生成器先发布消息到一个SNS主题,然后SQS队列订阅SNS主题有什么好处吗?我假设直接发布到 SQS 队列就足够了。
假设您不需要将消息散布给不同类型的工作人员,并且您的工作人员正在做同样的工作,那么不,您不需要。
每个工作人员可以接收和处理一条消息。
需要注意的一项是消息再次在 SQS 上可见之前的超时。即没有正确配置超时可能会导致另一个工作人员处理相同的消息。
When a consumer receives and processes a message from a queue, the
message remains in the queue. Amazon SQS doesn't automatically delete
the message. Because Amazon SQS is a distributed system, there's no
guarantee that the consumer actually receives the message (for
example, due to a connectivity issue, or due to an issue in the
consumer application). Thus, the consumer must delete the message from
the queue after receiving and processing it. Visibility Timeout
Immediately after a message is received, it remains in the queue. To
prevent other consumers from processing the message again, Amazon SQS
sets a visibility timeout, a period of time during which Amazon SQS
prevents other consumers from receiving and processing the message.
The default visibility timeout for a message is 30 seconds. The
minimum is 0 seconds. The maximum is 12 hours. For information about
configuring visibility timeout for a queue using the console
我有一个任务生成器来向 SQS 队列生成任务消息,还有一群工作人员轮询 SQS 队列来处理任务。在这种情况下,让任务生成器先发布消息到一个SNS主题,然后SQS队列订阅SNS主题有什么好处吗?我假设直接发布到 SQS 队列就足够了。
假设您不需要将消息散布给不同类型的工作人员,并且您的工作人员正在做同样的工作,那么不,您不需要。
每个工作人员可以接收和处理一条消息。
需要注意的一项是消息再次在 SQS 上可见之前的超时。即没有正确配置超时可能会导致另一个工作人员处理相同的消息。
When a consumer receives and processes a message from a queue, the message remains in the queue. Amazon SQS doesn't automatically delete the message. Because Amazon SQS is a distributed system, there's no guarantee that the consumer actually receives the message (for example, due to a connectivity issue, or due to an issue in the consumer application). Thus, the consumer must delete the message from the queue after receiving and processing it. Visibility Timeout
Immediately after a message is received, it remains in the queue. To prevent other consumers from processing the message again, Amazon SQS sets a visibility timeout, a period of time during which Amazon SQS prevents other consumers from receiving and processing the message. The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours. For information about configuring visibility timeout for a queue using the console