-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DLQ - Help wanted #10
Comments
Hi @pjsier! |
I think I found out what happens. |
When I have success or fail on process of a message, the message is droped from queue. def ack(self, message: "_SQSMessage") -> None:
message._sqs_message.delete()
self.message_refc -= 1
#: Messages are added to DLQ by SQS redrive policy, so no actions are necessary
nack = ack The SQS has three states of message (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html):
So, when I delete a message on Maybe the solution is on What is your opinion? |
Thanks for digging into this! Unfortunately, I haven't had time to look into this, but I'll try to take a look this weekend. |
Checking in on this. I'm looking to implement the SQS broker, but we use the Retry middleware pretty heavily |
@jairhenrique were you able to solve this issue? Have you considered not using Retries and instead : don't delete the message, let it regain visibility, and be retrieved by a worker again? I haven't tried retries with Dramatiq yet but I have the impression that since, as you write, Retry mechanism in practice creates a new message, SQS DLQ makes no sense if Retry is turned on at all. So we have a situation here: either we use DLQ or Retries. Am I getting it right? |
@januszm 's I tried using Retry along with the following
which does few following things
Note: Default |
@januszm @chintan-synapse I try it: import argparse
import dramatiq
import dramatiq
import random
import sys
from dramatiq_sqs import SQSBroker
broker = SQSBroker(
namespace="dramatiq_sqs_tests",
middleware=[],
dead_letter=True,
aws_access_key_id="xxxx",
aws_secret_access_key="xxx",
region_name="us-east-1"
)
dramatiq.set_broker(broker)
@dramatiq.actor
def add(x, y):
raise Exception('fake') And rewrite def ack(self, message: "_SQSMessage") -> None:
message._sqs_message.delete()
self.message_refc -= 1
#: Messages are added to DLQ by SQS redrive policy, so no actions are necessary
def nack(self, message: "_SQSMessage") -> None:
print('NACK')
pass Whem I raise I'm trying to figure out the best way to not ack the message and not call |
@januszm @chintan-synapse @Bogdanp I open this pr on dramatiq. If it make sense, I will change def ack(self, message: "_SQSMessage") -> None:
message._sqs_message.delete()
self.message_refc -= 1
def nack(self, message: "_SQSMessage") -> None:
self.message_refc -= 1 |
With this implementation, the def ack(self, message: "_SQSMessage") -> None:
message._sqs_message.delete()
self.message_refc -= 1
def nack(self, message: "_SQSMessage") -> None:
self.message_refc -= 1 I keep thinking of a solution. |
Hi Guys, We use dramatiq with SQS and do see a value in retries + DLQ - that way there is more certainty that the messages that will enter the DLQ are real bugs and not rumtime problems... |
We've got a workaround by forcing max_received to be 1 and overriding nack.
|
Current situationIt looks like the core The core
WorkaroundUsing @jamie-chang-globality's workaround does work to an extent (see limitation below) but still relies on the core retry logic that deletes and re-queues a message. Having SuggestionI believe we could have an If a DLQ is configured:
If a DLQs is not configured then:
This could allow the use of native SQS retries and DLQ routing. The functional change that this would likely have on retries is that it would mean that the retried message would:
AlternativeAn alternative would be to remove the native support for DLQ redrive policy and manually move tasks to DLQs @Bogdanp Do you have any opinions on this? As it functionally changes the concept of deleting and re-queueing messages for retries. |
@Bogdanp I've created an actor like this.
I have an error in this process and the worker exceed the number of retries
[dramatiq.middleware.retries.Retries] [WARNING] Retries exceeded for message 'd3c95e20-40b6-47ce-877b-fff43bcd5a57'.
but the message did not go to the dlq queue 🤔 .The number of
MAX_RECEIVES
default is 5 in dlq setup.Environment
Configs
The text was updated successfully, but these errors were encountered: