<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aditya gupta</title>
    <description>The latest articles on DEV Community by Aditya gupta (@adityagupta26).</description>
    <link>https://dev.to/adityagupta26</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F538486%2F33a9957e-a7a7-437c-ae7d-0ffbb8bceb09.png</url>
      <title>DEV Community: Aditya gupta</title>
      <link>https://dev.to/adityagupta26</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adityagupta26"/>
    <language>en</language>
    <item>
      <title>The message that gets processed twice</title>
      <dc:creator>Aditya gupta</dc:creator>
      <pubDate>Thu, 26 Nov 2026 19:51:58 +0000</pubDate>
      <link>https://dev.to/adityagupta26/the-message-that-gets-processed-twice-4c68</link>
      <guid>https://dev.to/adityagupta26/the-message-that-gets-processed-twice-4c68</guid>
      <description>&lt;p&gt;This story was written with the assistance of an AI writing program.&lt;/p&gt;

&lt;p&gt;Your worker processed the SQS message. So why did another worker process it again?&lt;/p&gt;

&lt;p&gt;Because receiving a message does not remove it from the queue. It hides it from other consumers for the length of the visibility timeout. If your worker does not delete the message before the timeout expires, it becomes visible again and another consumer can pick it up.&lt;/p&gt;

&lt;p&gt;The default is 30 seconds, starting from the moment the message is delivered. You are expected to process and delete within that window.&lt;/p&gt;

&lt;p&gt;Too short, and slow jobs can run twice. Too long, and failed messages take longer to reappear, so retries slow down. Match it to your real processing time.&lt;/p&gt;

&lt;p&gt;For jobs that run long, extend the timeout while you work:&lt;br&gt;
aws sqs change-message-visibility --queue-url  --receipt-handle  --visibility-timeout 300&lt;/p&gt;

&lt;p&gt;A heartbeat that calls this periodically keeps the message hidden until the job finishes. Setting the timeout to 0 hands the message back immediately. The hard cap is 12 hours from the first receive, and extending does not reset that.&lt;/p&gt;

&lt;p&gt;One more thing: standard SQS queues are at-least-once. Even inside the timeout, AWS does not guarantee a message will not be delivered more than once. Make your consumers idempotent instead of trusting the timeout.&lt;/p&gt;

&lt;p&gt;Check your queue's setting:&lt;br&gt;
aws sqs get-queue-attributes --queue-url  --attribute-names VisibilityTimeout&lt;/p&gt;

&lt;p&gt;Takeaway: the timeout hides a message; only DeleteMessage removes it. Tune the timeout, delete after success, and design for duplicates anyway.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F120b5ws6b9narv7vwcuk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F120b5ws6b9narv7vwcuk.png" alt="Diagram: SQS visibility timeout. Receive 1 starts the visibility window; receive 2 inside the window returns nothing; after expiry, receive 3 returns the message again." width="780" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>sre</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
