PHPackages                             mhujer/rabbit-mq-consumer-handler-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. mhujer/rabbit-mq-consumer-handler-bundle

ActiveLibrary[Queues &amp; Workers](/categories/queues)

mhujer/rabbit-mq-consumer-handler-bundle
========================================

Handle messages in RabbitMQ consumers in a safe and effective way

1.3.1(4y ago)05.5kMITPHPPHP ~7.4 || ~8.0

Since Apr 24Pushed 4y agoCompare

[ Source](https://github.com/mhujer/Rabbit-Mq-Consumer-Handler-Bundle)[ Packagist](https://packagist.org/packages/mhujer/rabbit-mq-consumer-handler-bundle)[ RSS](/packages/mhujer-rabbit-mq-consumer-handler-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (13)Versions (9)Used By (0)

RabbitMQ Consumer Handler Bundle
================================

[](#rabbitmq-consumer-handler-bundle)

**This package is a fork of [`vasek-purchart/rabbit-mq-consumer-handler-bundle`](https://github.com/VasekPurchart/Rabbit-Mq-Consumer-Handler-Bundle) maintained for newer PHP and Symfony versions.**

---

**Handle messages in RabbitMQ consumers in a safe and effective way**

> **Note:** This bundle expects you are using [RabbitMqBundle](https://github.com/eMAGTechLabs/RabbitMqBundle)

Message queue consumers require usually long running processes, which should process many different messages, before they are terminated. In an ideal scenario, they will be running indefinitely. But since we are not living in an ideal world, errors will inevitably occur. These can be typically:

- expected application exceptions,
- unexpected application exceptions,
- other exceptions and errors like connection interruptions etc.,
- memory leaks and other unexpected behavior.

The purpose of this bundle is to encapsulate handling of these states, automate the ones, which can be automated and provide comfortable ways to handle the remaining ones.

This bundle can automatically handle:

- stopping consumer on uncaught exceptions (so that it can be safely restarted)
- logging uncaught exceptions,
- clearing Doctrine EntityManager before processing a message,
- stopping consumer when Doctrine EntityManager is closed.

Usage
-----

[](#usage)

In order to receive all the benefits of automated handling you need only to run the message processing through the `ConsumerHandler`, so standard consumer could look something like this:

```
