Using aws' sns and sqs in Python

首先,sns = Simple Notification Service,sqs = Simple Queue Service

What is the difference between sns and sqs?

(ref:https://stackoverflow.com/questions/13681213/what-is-the-difference-between-amazon-sns-and-amazon-sqs

sns is a distributed publish-subscribe system. Once the publisher publishes, the subscriber can receive it immediately .

The subscriber (end point) of sns can be mail, sms, or even sqs , which is usually used when the number of subscribers is unknown

sqs is a distributed queue system, and messages are not pushed to subscribers by default.

The subscriber needs to poll to get the message .

Once a subscriber receives, processes or deletes the message, other subscribers will not receive the same message

How to use sns? (ref: https://gist.github.com/stuartmyles/8099723 )

In the case of ensuring that the key of aws is correct and consistent , it is also necessary to ensure that the target of publisher and subscriber is the same topic

怎样使用sqs?(ref:https://aws.amazon.com/cn/blogs/developer/using-python-and-amazon-sqs-fifo-queues-to-preserve-message-sequencing/

To use sqs, you need to create ( https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-getting-started.html ), you need to ensure that the key of aws is exactly the same as the key of the sender , and the QueueName must also be the same

You can also let sns act as publisher and receive with sqs. In this case, you need to use the  set_attributes method (ref: https://aws.amazon.com/cn/blogs/developer/subscribing-an-sqs-queue-to-an-sns-topic/https://docs .aws.amazon.com/sns/latest/dg/SendMessageToSQS.html )

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325908795&siteId=291194637