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 8331767
In Process

The Archive Base Latest Questions

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

SQS expects your application to be idempotent and I’ve got multiple consumers/producers where (even

  • 0

SQS expects your application to be idempotent and I’ve got multiple consumers/producers where (even if SQS had a deliver-once mechanism) I will have race conditions creating duplicates and race conditions consuming because my consumers run via cron jobs.

My current plan is to use the Django 1.4 select_for_update which should block other consumers on the same row, doing something like:

reminders = EmailReminder.objects.select_for_update().filter(id=some_id)
if not reminders[0].finished:
    reminder.send()
    reminder.update(finished=datetime.now())
# Delete job.

Are there better ways of dealing with this?

  • 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-09T02:31:02+00:00Added an answer on June 9, 2026 at 2:31 am

    Hook up django-celery to SQS and have it designate a periodic job using celerybeat. Then have celeryd worker(s) running on the same queue anywhere you want. Only one will pick up a job at a time and execute it. No need to introduce DB locking on any level.

    As long as your worker is guaranteed to finish its current task before celerybeat fires a new one you will never have a need for a lock. Now if you think there is a chance they may overlap you can introduce states for your notifications where:

    1. Any reminder starts in “unsent” state.
    2. Your celerybeat sends a request to process unsent emails to the queue.
    3. Some worker picks it up and grabs all of them.
    4. Immediately the worker transitions all of them to “sending” state.
    5. Proceeds to send them one at a time (or in bulk).
    6. If sending fails for any, revert their state back to unsent.
    7. For all that succeeded transition to sent.

    This way if celerybeat fires another job while your original job is not done with the initial batch, you won’t have duplicate emails sent. As an added bonus you can scale the solution and distribute the load.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple messages in SQS. The following code always returns only one, even
I'm currently developing an application in C# that uses Amazon SQS The size limit
I am implementing Amazon's SQS service in My Rails application. I am trying to
I'm working on an application whose workflow is managed by passing messages in SQS,
I'm implementing a task queue with Amazon SQS ( but i guess the question
I have a web app that sends messages to an Amazon SQS Queue. Amazon
I have developed a web service(using ruby/sinatra/sqs) which runs on Linux Red Hat. I
im looking to write a daemon that: reads a message from a queue (sqs,
I am trying to build a twitter-like follow mechanism. User takes an action. We
I would like to have my CI server use a SQS queue to send

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.