adtechpotok / messenger-adapter
Enqueue adapter for Symfony Messenger component
Installs: 211
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 55
Type:symfony-bundle
Requires
- doctrine/orm: *
- enqueue/amqp-tools: ^0.8.23
- enqueue/enqueue-bundle: ^0.8.0
- symfony/messenger: 4.1.3
- symfony/options-resolver: ^3.4|^4.1
Requires (Dev)
- phpunit/phpunit: ^7.1@dev
- symfony/yaml: ^3.4@dev|^4.1@dev
This package is not auto-updated.
Last update: 2024-12-19 18:05:34 UTC
README
This Symfony Messenger transport allows you to use Enqueue to send and receive your messages from all the supported brokers.
Usage
- Install the transport
composer req enqueue/messenger-adapter
- Configure the Enqueue bundle as you would normaly do (see Enqueue's Bundle documentation). If you are using the recipes, you should
just have to configure the environment variables to configure the
default
Enqueue transport:
# .env # ... ###> enqueue/enqueue-bundle ### ENQUEUE_DSN=amqp://guest:guest@localhost:5672/%2f ###< enqueue/enqueue-bundle ###
- Configure Messenger's transport (that we will name
amqp
) to use Enqueue'sdefault
transport:
# config/packages/messenger.yaml framework: messenger: transports: amqp: enqueue://default
- Route the messages that have to go through the message queue:
# config/packages/framework.yaml framework: messenger: # ... routing: 'App\Message\MyMessage': amqp
- Consume!
bin/console messenger:consume-messages amqp
Advanced usage
Configure the queue(s) and exchange(s)
In the transport DSN, you can add extra configuration. Here is the reference DSN (note that the values are just for the example):
enqueue://default
?queue[routingKey][name]=queue_name
&topic[name]=topic_name
&topic[type]=topic|fanout|direct
&deliveryDelay=1800
&delayStrategy=Enqueue\AmqpTools\RabbitMqDelayPluginDelayStrategy
&timeToLive=3600
&receiveTimeout=1000
&priority=1
Send a message on a specific topic
You can send a message on a specific topic using TransportConfiguration
envelope item with your message:
use Enqueue\MessengerAdapter\EnvelopeItem\TransportConfiguration; // ... $this->bus->dispatch((new Envelope($message))->with(new TransportConfiguration( ['topic' => 'specific-topic'] )));