RabbitMQ serves as a message broker, responsible for sending and receiving messages through queues.
·?????? Producer is in charge of sending messages
·?????? Consumer retrieves messages from the queue
·?????? Queue is a fundamental component of the message broker architecture, storing messages from producers and forwarding them to consumers.
Messages aren’t directly pushed into queues. Instead, they pass through exchanges, which route messages to specific queues using keys or routes. Exchange types include:
- Direct: Messages are routed based on the routing key
- Topic: Routing key matches routing pattern via wildcards
- Fanout: Messages are delivered to all bound queues regardless of the key
- Headers: Similar to a topic exchange, but routing relies on header values.
RabbitMQ and server concepts
Some important concepts need to be described before we dig deeper into RabbitMQ. The default virtual host, the default user, and the default permissions are used in the examples, so let’s go over the elements and concepts:
- 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 TCP connection between your application and the RabbitMQ broker.
- Channel: A virtual connection inside a connection. When 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: A key that the exchange looks at to decide how to route the message to queues. Think of the routing key like an address for the message.
- 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 for specific virtual hosts.
- Vhost, virtual host: Provides a way to segregate applications using the same RabbitMQ instance. Different users can have different permissions to different vhost and queues and exchanges can be created, so they only exist in one vhost.
.Net Core | C# | Azure | JavaScript | Microservices | D365 | Solutions Architect | Team Lead | Mentor
1 年A good summary on RabbitMQ. Keep writing
FSD|Azure|Cosmos, postgresql, docker,|AKS|DevOps|Dot.Net Core/.Net5/6/7/8 ||xunit,nunit, integration, graphQL,gRpc | EFCore|API |WCF| Angular/React |Microservices,DDD/TDD| Dapper | Sonar Mob: +919715783720/+6580537622
1 年Nice