-
Docker image:
$ docker run -d -it --rm --network my_network
-p 5672:5672 -p 15672:15672
--name rabbitmq
rabbitmq:management This command has no security for the web console Secured Docker broker image:$ docker run -d -it --rm --network my_network
-p 5672:5672 -p 15672:15672
--name rabbitmq
-e RABBITMQ_DEFAULT_USER=
-e RABBITMQ_DEFAULT_PASS=
rabbitmq:management
- Fanout(No routing)
- Direct(Routing match)
- Topic(Routing Pattern Match)
- Headers(Header match)
NB: By default the broker works as direct routing. Routing is the connection of producer and exchange. Binding checks the relation between exchange and queue, consumer
[Provider]------------(Routing)------->Exchange-------(Bing)--------->queue(1....n)---------->[Consumer]
Usecase:
-
As Worker:
-- There could be a scenario where the main server may have some module that can process the image
-- But the single module can not process images from different users at a time quickly. And the server become boomed
-- Here we can distribute the processing module in some seperate service. Each service will take an image single time
-- This process of handling one image processing task for one server will be handled by broker
-- Request will come to the Main server to process images. Main server will send the request to the Broker
-- Broker will distribute the task with balanced round robin algorithm among the servers
-- Additional Features: Need to persist the data and queue even after broker restart
Flow
[API_Request]--------->[Main_Server]------->[Broker]-----(Distribute)----[Image_Processing_Services(1----n)]
-
Pub/Sub(Fanout)
-- This work will required Exchange to introduce
-- Producer will send the message to the exchange without any routing key
-- Consumer will subscribe to the exchange with queue and will get all the message
-
Routing(Direct)-->store different log in different server
-- Here Producer will send message to the exchange with exchangeName and routing key
-- Consumer will subscribe exchange with a routing key.
-- Consumer will get the message only if the routing key matches
-
Topics:
-- Producer will send message to the exchange with exchangeName and routing key
-- Consumer will subscribe exchange with a routing key and a topic