DEV Community


RabbitMQ in Laradock

dendihandian profile image Dendi Handian Updated on ・2 min read

Previously on the PHP-Worker in Laradock, we have tried to use queue by using the database connection by enqueueing the jobs inside the jobs table and run the queue worker using php-worker container. Now let's try to use external service (other than our laravel app) for queue processing, they usually called message-broker.

One of the best message-broker at the moment is RabbitMQ and luckily, Laradock has it. Let's try it out!

Run the RabbitMQ container

Just at ease as usual, go inside your laradock directory by using your favorite CLI and execute this command:

docker-compose up -d rabbitmq
Enter fullscreen mode Exit fullscreen mode

The above command will download the rabbitmq docker image and build it for the first time (make sure you had an internet connection). After it finished creating, you can check the container status using docker-compose ps here what I got:

           Name                          Command               State                                                     Ports
laradock_docker-in-docker_1            Up      2375/tcp, 2376/tcp
laradock_php-fpm_1            docker-php-entrypoint php-fpm    Up      9000/tcp
laradock_rabbitmq_1  rabbi ...   Up>15671/tcp,>15672/tcp, 25672/tcp, 4369/tcp, 5671/tcp,>5672/tcp
laradock_workspace_1          /sbin/my_init                    Up>22/tcp,>8000/tcp,>8080/tcp
Enter fullscreen mode Exit fullscreen mode

and when we check the resource used by the container(s) using docker stats, here what I got:

CONTAINER ID        NAME                          CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
851befcbcc87        laradock_rabbitmq_1           69.30%              88.38MiB / 3.846GiB   2.24%               245kB / 765kB       0B / 119kB          88  
e940b1ebf50c        laradock_php-fpm_1            0.00%               7.703MiB / 3.846GiB   0.20%               1.91kB / 0B         123kB / 0B          3   
bfb04cbeba8d        laradock_workspace_1          0.00%               9.16MiB / 3.846GiB    0.23%               4.31kB / 0B         7.22MB / 57.3kB     6 
f7a90b272d84        laradock_docker-in-docker_1   0.19%               20.43MiB / 3.846GiB   0.52%               2.43kB / 0B         2.55MB / 918kB      23
Enter fullscreen mode Exit fullscreen mode

Accessing the RabbitMQ Management (Web UI)

The rabbitmq management should be accessible at http://localhost:15672/#/ and the default login credential is guest for both username and password.

Once you get in, the user interface should be like this:


Laravel Queue using RabbitMQ

I have an idea to create another post series about laravel packages. So for the rabbitmq demo in Laravel, I will separate it here.

Have fun experimenting RabbitMQ in laradock!

Discussion (0)

Editor guide