arthem / rabbit-bundle
Simple RabbitMQ bundle
Installs: 15 371
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.4
- ext-json: *
- php-amqplib/rabbitmq-bundle: ^2.7
- psr/log: ^1
- symfony/console: ^4|^5|^6
- symfony/framework-bundle: ^4|^5|^6
Requires (Dev)
- doctrine/orm: ^2.8
- phpunit/phpunit: ^9.5
- symfony/console: ^6
- symfony/framework-bundle: ^6
- symfony/process: ^6
- twig/extensions: ^1.5
Suggests
- ext-openssl: *
- doctrine/orm: ^2.3
- twig/extensions: ^1.5
README
A simple and faster setup to work with consumer through handlers.
Installation
composer require arthem/rabbit-bundle
Add auto-tag feature:
# config/services.yaml services: # ... _instanceof: # ... Arthem\Bundle\RabbitBundle\Consumer\Event\EventMessageHandlerInterface: tags: ['arthem_rabbit.event_handler']
Handlers
Every message are based on type which allow to define their corresponding handler. A handler can support multiple types. Handlers and types can be split into queues
By default, this bundle configures:
- one queue named
event
- its direct exchange named
x-event
- the corresponding consumer named
event
In opposite to RabbitMQBundle, this one provides only one message producer. The message type allows to send message to the appropriate exchange.
Failure
Failed message processing can be logged in a database table.
First enable the feature:
# config/packages/arthem_rabbit.yaml arthem_rabbit: failure: ~
Create your own Entity which must implement Arthem\Bundle\RabbitBundle\Model\FailedEventInterface
:
<?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Arthem\Bundle\RabbitBundle\Model\FailedEvent as BaseFailedEvent; /** * @ORM\Entity */ class FailedEvent extends BaseFailedEvent { /** * @var string * * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue */ protected $id; public function getId(): string { return (string)$this->id; } }