How RabbitMQ Works and RabbitMQ Core Concepts
https://www.javaguides.net/2018/12/how-rabbitmq-works-and-rabbitmq-core-concepts.html
n this quick article, we will learn what is RabbitMQ, how it works and core concepts of RabbitMQ.
RabbitMQ
is an open source message broker software. It accepts messages from
producers and delivers them to consumers. It acts like a middleman which
can be used to reduce loads and delivery times taken by web application
servers.
How RabbitMQ Works?
- 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. exchange可以把message发给不同的queue,就依靠binding来决定
- 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.

The message will be picked up and consumed from the queue; this is called ‘Consuming’.
Send Message to Multiple Queues

Sending messages to multiple queues exchange is connected to the queues by the binding and the routing key.
A Binding is a “link” that you set up to connect a queue to an exchange. The Routing key is a message attribute. The exchange might look at this key when deciding how to route the message to queues (depending on exchange type).
Exchanges

The message flow in RabbitMQ
- The producer publishes a message to an exchange. When you create the exchange, you have to specify the type of it. The different types of exchanges are explained in detail later on.
- The exchange receives the message and is now responsible for the routing of the message. The exchange takes different message attributes into account, such as routing key, depending on the exchange type.
- Bindings have to be created from the exchange to queues. In this case, we see two bindings to two different queues from the exchange. The Exchange routes the message into the queues depending on message attributes.
- The messages stay in the queue until they are handled by a consumer
- The consumer handles the message.
Types of Exchanges

- Direct: A direct exchange delivers messages to queues based on a message routing key.
- Fanout: A fanout exchange routes messages to all of the queues that are bound to it.
- Topic: The topic exchange does a wildcard match between the routing key and the routing pattern specified in the binding.
- Headers: Headers exchanges use the message header attributes for routing.
RabbitMQ Core 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 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.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2019-06-12 Remote desktop manager共享账号
2019-06-12 content is not supported outside 'script" or asp content' region
2019-06-12 How to pass values across the pages in ASP.net without using Session
2019-06-12 GitLab Flow
2017-06-12 编译项目的时候,不会编译依赖的类库项目
2017-06-12 CSS 链接
2015-06-12 Task-based Asynchronous Pattern (TAP)