Skip to main content

Overview

Broccoli includes built-in retry handling for failed messages. When a message handler returns an error, the message can be automatically re-queued for another attempt.

Default behavior

By default, Broccoli:
  • Enables retries for failed messages
  • Allows up to 3 retry attempts
  • Moves messages to a failed queue after exhausting retries

Configuring retry strategy

Use RetryStrategy when building your queue:

RetryStrategy options

with_attempts(n)

Set the maximum number of retry attempts:

retry_failed(bool)

Enable or disable retries entirely:

How retries work

Tracking attempts

Each BrokerMessage includes an attempts field:

Custom error handling

For fine-grained control, use process_messages_with_handlers:

Best practices

Design your message handlers to be idempotent. Since messages may be retried, the same message could be processed multiple times.
Consider whether failures are transient (network issues, temporary unavailability) or permanent (invalid data, business rule violations).
Broccoli doesn’t include built-in backoff, but you can implement it in your handler:

Failed message queue

Messages that exceed the retry limit are moved to a failed queue ({queue_name}:failed). You can:
  • Monitor this queue for alerting
  • Manually inspect and retry failed messages
  • Use the management API to retrieve queue status