How to get messages receive count in Amazon SQS using boto library in Python?

前端 未结 5 1921
不知归路
不知归路 2021-02-09 00:29

I am using boto library in Python to get Amazon SQS messages. In exceptional cases I don\'t delete messages from queue in order to give a couple of more changes to recover tempo

5条回答
  •  离开以前
    2021-02-09 01:06

    It should be done in few steps.

    1. create SQS connection :- sqsconnrec = SQSConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    2. create queue object :- request_q = sqsconnrec.create_queue("queue_Name")
    3. load the queue messages :- messages= request_q.get_messages()
    4. now you get the array of message objects and to find the total number of messages :- just do len(messages)

    should work like charm.

提交回复
热议问题