Broadway: Trying to send a message back to the queue it came from in handle_failed/2

Hey there, in case of any error in my processing of a message, i want to send it back to the SQS queue once more with a flag so that i can send it to a dead letter queue if it fails again, however i dont see my batchers inspect and i just get a stacktrace in my iex. Im purposely raising an exception so that it triggers the callback for testing. I unfortunately cant send my stacktrace but its just essentially the error test that i am raising in another function that handles the message process

Hey @mattmartian, welcome! The message is not acknowledged to SQS until it succeeds, so you don’t need to return it to the queue. It won’t be removed from the queue unless Broadway acknowledges it as successful. For dead letter queueing, you can simply configure your SQS queue to move items to a dead letter queue after a certain number of failures.


So in the event of a error (i.e a process not being alive at the time i need it) will it automatically retry? i guess the context in which im doing this is that in case if anything happens while processing the message i want it to start back at the beginning, and if it keeps failing just send it directly to the DLQ @benwilson512

That is correct! Do note that any database records you’ve written to that point are not automagically removed unless it fails inside of a transaction, so if you are doing side effect stuff like that you’ll want to make it idempotent or remove them in handle_failed

1 Like

okay cool! thanks, i was racking my brain on why it wouldnt go to the other batcher hahaha