Rabbit Consumer

Set up production-grade RabbitMQ consumption with a single attribute. Built-in reconnection, graceful shutdown, and health checks replace custom consumer process management scripts.

You'll know you need this when:

  • Your custom RabbitMQ consumer scripts need manual connection handling, reconnection logic, and shutdown management

  • Consumer processes crash on connection drops and require external restart supervision

  • You need health checks and graceful shutdown for containerized deployments

  • You want to combine consumption with instant retry, error channels, and deduplication declaratively

circle-check

Consume Messages from Queue

To consume Messages from Queue, it's enough to mark given method with AmqpConsumer attribute:

#[RabbitConsumer(
    endpointId: 'orders_consumer',
    queueName: 'orders'
)]
public function handle(string $payload): void
{
    // handle
}

And then we can run related process using endpoint Id "orders_consumer". Read more on running asynchronous processes in related section.

Automatic Conversion

If we have our Custom Conversion or JMS Module installed, then we can leverage automatic conversion:

Read more about Conversion in related section.

Instant Retry

In case of failure we may try to recover instantly. To do so we can provide InstantRetry attribute:

Read more about Instant Retry in related section.

Error Channel

To handle Message when failure happen, we may decide to send it to Error Channel. This can be used to for example store the Message for later review.

Read more about Error Channel in related section.

Final Failure Strategy

We can also define in case of unrecoverable failure, what should happen:

Read more about final failure strategy in related section.

Deduplication

We can define custom deduplication key to ensure no same Message will be handled twice.

Read more about deduplication in related section.

Last updated

Was this helpful?