The project needs a maintainer. Please comment on the issue if you want to maintain this project.
This Symfony Messenger transport allows you to use Enqueue to send and receive your messages from all the supported brokers.
- 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
In the transport DSN, you can add extra configuration. Here is the common reference DSN (note that the values are just for the example):
enqueue://default
?queue[name]=queue_name
&topic[name]=topic_name
&deliveryDelay=1800
&delayStrategy=Enqueue\AmqpTools\RabbitMqDelayPluginDelayStrategy
&timeToLive=3600
&receiveTimeout=1000
&priority=1
You can send a message on a specific topic using TransportConfiguration
envelope item with your message:
use Symfony\Component\Messenger\Envelope;
use Enqueue\MessengerAdapter\EnvelopeItem\TransportConfiguration;
// ...
$this->bus->dispatch((new Envelope($message))->with(new TransportConfiguration(
['topic' => 'specific-topic']
)));
See https://www.rabbitmq.com/tutorials/tutorial-five-php.html
You can use specific topic and queue options to configure your AMQP exchange in topic
mode and bind it:
enqueue://default
?queue[name]=queue_name
&queue[bindingKey]=foo.#
&topic[name]=topic_name
&topic[type]=topic
&deliveryDelay=1800
&delayStrategy=Enqueue\AmqpTools\RabbitMqDelayPluginDelayStrategy
&timeToLive=3600
&receiveTimeout=1000
&priority=1
Here is the way to send a message with a routing key matching this consumer:
$this->bus->dispatch((new Envelope($message))->with(new TransportConfiguration([
'topic' => 'topic_name',
'metadata' => [
'routingKey' => 'foo.bar'
]
])));