Rabbitmq 简明教程

RabbitMQ - Overview

What is RabbitMQ?

RabbitMQ 是一个用 Java 编写的开源消息代理。它完全符合 JMS 1.1 标准。它由 Apache 软件基金会开发和维护,并根据 Apache 许可证获得许可。它为企业级消息传递应用程序提供高可用性、可扩展性、可靠性、性能和安全性。

RabbitMQ is an open source message broker written in Java. It’s fully compliant with JMS 1.1 standards. It is developed and maintained by Apache Software Foundation and is licensed under Apache license. It provides high availability, scalability, reliability, performance and security for enterprise level messaging applications.

JMS 是一项允许开发基于消息的系统的规范。RabbitMQ 作为消息代理,位于应用程序之间,并允许它们以异步且可靠的方式进行通信。

JMS is a specification that allows development of message based system. RabbitMQ acts as a broker of messages which sits in between applications and allows them to communicate in asynchronous and reliable way.

amq

Types of Messaging

为了便于理解,下面解释了两种类型的消息传递选项。

There are two types of messaging options explained below for better understanding.

Point to Point

在这种通信方式中,代理只会向一个消费者发送消息,而其他消费者将等待从代理获得消息。没有消费者会收到相同的消息。

In this type of communication, the broker sends messages to only one consumer, while the other consumers will wait till they get the messages from the broker. No consumer will get the same message.

如果没有消费者,代理将一直持有消息,直到它得到消费者。这种通信方式也称为 Queue based communication ,生产者将消息发送到队列,并且只有一个消费者从队列中获取一条消息。如果有超过一个消费者,他们可能会获得下一条消息,但他们不会收到与其他消费者相同的消息。

If there are no consumers, the Broker will hold the messages till it gets a consumer. This type of communication is also called as Queue based communication where the Producer sends messages to a queue and only one consumer gets one message from the queue. If there is more than one consumer, they may get the next message but they won’t get the same message as the other consumer.

point to point messaging

Publish/Subscribe

在这种通信方式中,代理会向所有活跃的消费者发送消息的同份副本。这种通信方式也称为 Topic based communication ,代理向所有为特定主题订阅的活跃消费者发送相同的消息。此模型支持单向通信,其中不期望对已传输的消息进行验证。

In this type of communication, the Broker sends same copy of messages to all the active consumers. This type of communication is also known as Topic based communication where broker sends same message to all active consumer who has subscribed for particular Topic. This model supports one-way communication where no verification of transmitted messages is expected.

publish subscribe messaging