Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:58:58+00:00 2026-06-09T17:58:58+00:00

I am using boto library in Python to get Amazon SQS messages. In exceptional

  • 0

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 temporary failures. But I don’t want to keep receiving failed messages constantly. What I would like to do is either delete messages after receiving more than 3 times or not get message if receive count is more than 3.

What is the most elegant way of doing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:59:00+00:00Added an answer on June 9, 2026 at 5:59 pm

    There are at least a couple of ways of doing this.

    When you read a message in boto, you receive a Message object or some subclass thereof. The Message object has an “attributes” field that is a dict containing all message attributes known by SQS. One of the things SQS tracks is the approximate # of times the message has been read. So, you could use this value to determine whether the message should be deleted or not but you would have to be comfortable with the “approximate” nature of the value.

    Alternatively, you could record message ID’s in some sort of database and increment a count field in the database each time you read the message. This could be done in a simple Python dict if the messages are always being read within a single process or it could be done in something like SimpleDB if you need to record readings across processes.

    Hope that helps.

    Here’s some example code:

    >>> import boto.sqs
    >>> c = boto.sqs.connect_to_region()
    >>> q = c.lookup('myqueue')
    >>> messages = c.receive_message(q, num_messages=1, attributes='All')
    >>> messages[0].attributes
    {u'ApproximateFirstReceiveTimestamp': u'1365474374620',
     u'ApproximateReceiveCount': u'2',
     u'SenderId': u'419278470775',
     u'SentTimestamp': u'1365474360357'}
    >>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Python library boto to connect to Amazon S3 and create buckets
I'm using the boto library in Python to connect to DynamoDB. The following code
I have a python script using the boto library on ec2 instance which is
I am writing a script using boto and Python to automatically launch an Amazon
I'm using the python boto library and wrote a script (which runs on an
How can I create a folder under a bucket using boto library for Amazon
i am using the boto python module for polling amazon ec2 instances, however it
I'm trying to get itemName() from a simpleDB select query using boto, but doing
I'm using python boto and threading to download many files from S3 rapidly. I
How can I add steps to a waiting Amazon EMR job flow using boto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.