The first presentation of Bucharest PHP Mettup on getting started with RabbitMQ. The code of the demo can be found on github https://github.com/Overdeath/phprabbitmqdemo
4. Agenda
1. Common architecture for a queue system
2. Common use cases for queues
3. RabbitMQ demo
a. Setting up an exchange
b. Setting up a queue
c. Publishing a message
d. Consuming a message
4. PHP usage demo
a. Setting up an exchange
b. Setting up a queue
c. Publishing messages
d. Consuming messages
5. Tales from production
7. Common use cases
1. Communication between apps/components
a. Data sync
b. Using different languages
2. Asynchronous processing
a. Off loading web servers of heavy requests
b. Handle spikes without crashing
c. Handling systems with different SLAs
d. Scaling when needed
3. Batching
9. Installing RabbitMQ
1. Install erlang
a. wget -O - 'https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc' | sudo apt-key add -
b. echo "deb http://dl.bintray.com/rabbitmq/debian bionic erlang" | sudo tee /etc/apt/sources.list.d/bintray.erlang.list
c. sudo apt-get update
d. sudo apt-get install erlang-nox
2. Install Rabbit mq
a. wget -O - 'https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc' | sudo apt-key add -
b. echo "deb https://dl.bintray.com/rabbitmq/debian bionic main" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
c. sudo apt-get update
d. sudo apt-get install rabbitmq-server
3. Enable rabbit mq management-ui:
a. rabbitmq-plugins enable rabbitmq_management
4. Create a new user
a. rabbitmqctl add_user test test
b. rabbitmqctl set_user_tags test administrator
c. rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
11. Tales from production
1. Publish rate and consume rate should be similar
2. Entity deduplication
3. Publish order is not always the same as processing order
4. Processing messages more than once
5. One message can hang up the whole system
6. Loss of messages is inevitable
7. Long running processes in PHP can be a handful
Editor's Notes
Interfata rabbitMq
Creeare vhost
Creeare exchange fanout + o coada
Adaugare inca o coada la exchange fanout
Creeare exchange topic + 2 cozi
Publicare mesaj care merge pe una din cozi
Publicare mesaje care merg alternativ pe anumite cozi
Cod PHP
Instalare librarie amqp
Config
Publicare mesaje
Citire mesaje cu 1 worker
Folosire supervisor.d si scalare la 10 workeri