Skip to content

Retrying a message

Bruno Antunes edited this page Oct 3, 2018 · 11 revisions

Good news - you don't need to do anything to retry a message, SQS will handle that automatically for you. Basically do not call sqs_msg.delete if you want to retry a message. The message will become available again when it reaches the visibility_timeout.

class MyWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'default', auto_delete: true

  def perform(sqs_msg, body)
    do_something(sqs_msg, body) # raises an exception

The example above will cause the message to be available again in case the do_something raises an exception. When auto_delete is set to true, Shoryuken will auto delete the message in case of the worker doesn't raise an exception.

Check the Dead Letter Queue documentation to prevent the message being processed forever.

Exponential backoff

Shoryuken also supports exponential backoff, have a look at retry_intervals for more details.

You can’t perform that action at this time.