Step 32: Using RabbitMQ as a Message Broker
Using RabbitMQ as a Message Broker
To use RabbitMQ instead of PostgreSQL as a message broker:
patch_file
As you might have guessed, we also need to add RabbitMQ to the Docker Compose stack:
patch_file
+++ b/docker-compose.yaml
@@ -21,3 +21,7 @@ services:
redis:
image: redis:5-alpine
ports: [6379]
+
+ rabbitmq:
+ image: rabbitmq:3.7-management
+ ports: [5672, 15672]
To force Docker Compose to take the RabbitMQ container into account, stop the containers and restart them:
Or from the web debug toolbar:
Use guest
/guest
to login to the RabbitMQ management UI:
Adding RabbitMQ to the production servers can be done by adding it to the list of services:
--- a/.symfony/services.yaml
+++ b/.symfony/services.yaml
rediscache:
type: redis:5.0
+
+ type: rabbitmq:3.7
+ disk: 1024
+ size: S
Reference it in the web container configuration as well and enable the amqp
PHP extension:
patch_file
When the RabbitMQ service is installed on a project, you can access its web management interface by opening the tunnel first:
$ symfony tunnel:open
$ symfony open:remote:rabbitmq
# when done
Going Further
- .
This work, including the code samples, is licensed under a Creative Commons BY-NC-SA 4.0 license.