You can never understand everything but you should push yourself to understand the system.
-Ryan Dahl (creator of Node.JS)
This repository aims to explain the 'WHAT', 'WHY' and 'HOW' of RabbitMQ and MicroServices in a simplifieid manner.
- A bit of History!
- What is a Microservice?
- What is RabbitMQ?
- Fundamentals.
- When and why should you use RabbitMQ?
- Message flow in RabbitMQ.
- Setting up RabbitMQ.
- Using RabbitMQ with Node(AMQPLIB library)
- A simple program.
- All about Exchanges.
- Keywords.
- Useful Links.
- Producer, exchange and consumer make up the flow.
- The producer publishes a message to the exchange.
- The exchange receives the message and is now responsible for the routing of the message.
- A binding has to be set up between the queue and the exchange. In this case, we have bindings to two different queues from the exchange.
- The exchange routes the message in to the queues.
- The messages stay in the queue until they are handled by a consumer.
- The consumer handles the message.
The fanout copies and routes a received message to all queues that are bound to it regardless of routing keys or pattern matching as with direct and topic exchanges. Keys provided will simply be ignored.
Topic exchanges route messages to queues based on wildcard matches between the routing key and something called the routing pattern specified by the queue binding. Messages are routed to one or many queues based on a matching between a message routing key and this pattern.
Headers exchanges route based on arguments containing headers and optional values. Headers exchanges are very similar to topic exchanges, but it routes based on header values instead of routing keys. A message is considered matching if the value of the header equals the value specified upon binding.
- Producer: Application that sends the messages.
- Consumer: Application that receives the messages.
- Queue: Buffer that stores messages.
- Message: Information that is sent from the producer to a consumer through RabbitMQ.
- Connection: A connection is a TCP connection between your application and the RabbitMQ broker.
- Channel: A channel is a virtual connection inside a connection. When you are publishing or consuming messages from a queue - it's all done over a channel.
- Exchange: Receives messages from producers and pushes them to queues depending on rules defined by the exchange type. To receive messages, a queue needs to be bound to at least one exchange.
- Binding: A binding is a link between a queue and an exchange.
- Routing key: The routing key is a key that the exchange looks at to decide how to route the message to queues. The routing key is like an address for the message.
- AMQP:AMQP (Advanced Message Queuing Protocol) is the protocol used by RabbitMQ for messaging.
- Users: It is possible to connect to RabbitMQ with a given username and password. Every user can be assigned permissions such as rights to read, write and configure privileges within the instance. Users can also be assigned permissions to specific virtual hosts.
- Vhost, virtual host: A Virtual host provides a way to segregate applications using the same RabbitMQ instance. Different users can have different access privileges to different vhost and queues and exchanges can be created, so they only exist in one vho