How to get all messages in Amazon SQS queue using boto library in Python?

后端 未结 6 2100
陌清茗
陌清茗 2021-02-05 10:49

I\'m working on an application whose workflow is managed by passing messages in SQS, using boto.

My SQS queue is growing gradually, and I have no way to check how many e

6条回答
  •  花落未央
    2021-02-05 11:06

    Put your call to q.get_messages(n) inside while loop:

    all_messages=[]
    rs=q.get_messages(10)
    while len(rs)>0:
        all_messages.extend(rs)
        rs=q.get_messages(10)
    

    Additionally, dump won't support more than 10 messages either:

    def dump(self, file_name, page_size=10, vtimeout=10, sep='\n'):
        """Utility function to dump the messages in a queue to a file
        NOTE: Page size must be < 10 else SQS errors"""
    

提交回复
热议问题