Image resize service using Go & RabbitMQ. The client loads an image and sends it to the server, which will resize the image and sends it back to the client. The client will then save the resized image to the working directory.
On Debian Linux, execute the following command:
# apt-get install rabbitmq-server
# systemctl enable rabbitmq-server
# systemctl start rabbitmq-server
# systemctl status rabbitmq-server
The last command should show output similar to
● rabbitmq-server.service - RabbitMQ Messaging Server
Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; ena>
Active: active (running) since Mon 2021-05-17 08:22:46 CEST; 5mi>
Main PID: 7730 (beam.smp)
Status: "Initialized"
Tasks: 162 (limit: 19101)
Memory: 88.0M
CPU: 8.878s
CGroup: /system.slice/rabbitmq-server.service
├─7730 /usr/lib/erlang/erts-11.1.8/bin/beam.smp -W w -K >
├─7941 erl_child_setup 65536
├─8015 inet_gethost 4
└─8016 inet_gethost 4
May 17 08:22:42 tessa systemd[1]: Starting RabbitMQ Messaging Server.>
May 17 08:22:46 tessa systemd[1]: Started RabbitMQ Messaging Server.
RabbitMQ does not install a management console by default, but the optional web-based plugin makes it easy to peek into a running RabbitMQ instance.
# rabbitmq-plugins enable rabbitmq_management
Open the URL http://localhost:15672/
with a browser. A login screen should now be shown:
The default user is *guest and the default password is also guest. After login in, the following screen is shown:
It is a good idea to change the password of the guest user:
# rabbitmqctl change_password guest new_password
# rabbitmqctl add_vhost image-resizer
Refresh the web UI. It should now show the image-resizer vhost:
Next we need to allow the guest user to access the image-resizer vhost:
# rabbitmqctl set_permissions -p image-resizer guest ".*" ".*" ".*"
ampq is a RabbitMQ library for Python.
$ go get github.com/streadway/amqp
Imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.).
$ go get -u github.com/disintegration/imaging
The RabbitMQ username and password need to be passed as command line arguments:
First start the server, then the client.