This post is part 2 of a 4 part series:
In this post we are going to set up rabbitMQ a message broker that is simple to use, fairly low level. Comes highly recommended for development environments. It's it pretty low level so a lot of people recommend using something else in production.
- Text Editor
- command window (cmd, bash, or powershell)
- Docker - Docker for windows (using linux containers)
- Docker-Compose - comes with docker for windows
- notepad++ or visual studio code
If you are a windows user make sure that you set docker to run linux containers. There's not much in this domain that has an official windows image.
First create a directory to work in, call it what you want, it only matters that all of your work goes in there.
Then create two files, docker-compose.yml and docker-compose.override.yml.
Note: white space is important in yml files
Open docker-compse.yml and at the top enter
rabbitmq: image: rabbitmq:management-alpine
open docker-compose.override.yml and enter
rabbitmq: ports: 15672:15672
save both files.
I chose the management-alpine tags for rabbit because the management tag adds the admin site to the image and alpine is linux distribution designed to be lightweight for docker images similar to Microsoft's nano server.
docker-compose is the main file where you typically include your images. the override file allows you to merge the two together to generate the the compose file that is actually used. This allows you to designate what you want to run in one file and configure it differently between environments just by passing in a new override file.
In our case
docker-compose is holding the image.
docker-compose is holding the ports.
the ports binds 15672 port of the container to the 15672 port of the machine allowing you to access rabbitmq by going http://localhost:15675.
open a command window and navigate to the directory.
this builds all of the images in the compose file and runs the containers. In this case only rabbitmq.
you should see it pulling the image and then the logs as it starts up. When the logs quit moving you should be able to go to http://localhost:15675
From there you can play around with exchanges and queues so that you can get a feel for them.
Here is some documentation. https://www.rabbitmq.com/tutorials/amqp-concepts.html
Here are some commands that may come in handy while you are messing with rabbit and containers in general.
docker exec <ContainerName> <script>
this allows you to run scripts in side of a running docker container.
docker exec -it <ContainerName> bash
This allows you to open a bash console inside of the container so you can search around inside and find things. Which leads to the next commands.
dpcker cp <ContainerName>:<path/inside/container <pathToStore>
This allows you to copy files from the container to a local directory which is a good way to get the starting point for your configuration files
docker cp <ContainerName>:/etc/rabbitmq/ c:/rabbitmq
this scripts copies the rabbitmq folder to c:/rabbitmq. This folder contains the configuration files for RabbitMq.
Now we have a message broker that we can send messages to. In the next part we will set up elastic search and kibana.