美文网首页
RabbitMQ备注

RabbitMQ备注

作者: 良人与我 | 来源:发表于2019-04-06 22:58 被阅读0次

RabbitMQ is a post box, a post office and a postman.
RabbitMQ, and messaging in general, uses some jargon.
RabbitMQ 中的专有名词

名称 描述
producer Producing means nothing more than sending. A program that sends messages is a producer
queue A queue is the name for a post box which lives inside RabbitMQ. Although messages flow through RabbitMQ and your applications, they can only be stored inside a queue. A queue is only bound by the host's memory & disk limits, it's essentially a large message buffer. Many producers can send messages that go to one queue, and many consumers can try to receive data from one queue.
consumer Consuming has a similar meaning to receiving. A consumer is a program that mostly waits to receive messages:
connection The connection abstracts the socket connection, and takes care of protocol version negotiation and authentication and so on for us. Here we connect to a broker on the local machine - hence the localhost. If we wanted to connect to a broker on a different machine we'd simply specify its name or IP address here.
channel where most of the API for getting things done resides

发送方式

named queue

image.png

Work Queues

image.png

Publish/Subscribe

image.png

There are a few exchange types available: direct, topic, headers and fanout

exchange type desc
fanout The fanout exchange is very simple. As you can probably guess from the name, it just broadcasts all the messages it receives to all the queues it knows.
direct The routing algorithm behind a direct exchange is simple - a message goes to the queues whose binding key exactly matches the routing key of the message.
topic Messages sent to a topic exchange can't have an arbitrary routing_key - it must be a list of words, delimited by dots. The words can be anything, but usually they specify some features connected to the message. A few valid routing key examples: "stock.usd.nyse", "nyse.vmw", "quick.orange.rabbit". There can be as many words in the routing key as you like, up to the limit of 255 bytes.

direct exchage

image.png

这个图以日志为例,C1 只想打印error 日志到文件,而C2 需要打印所有日志到控制台。Q1 需要 绑定 exchange 通过 routeKey error 。
而 Q2 需要绑定 exchange 通过 routeKey info 、 error 、warning 。

topic exchage

image.png

topic exchange 和 direct exchange 的主要区别是binding key 的 形式。
不是通过具体的key ,而是通过规则去匹配。

* (star) can substitute for exactly one word.
# (hash) can substitute for zero or more words.

参考地址
https://www.rabbitmq.com/tutorials/tutorial-one-java.html

相关文章

网友评论

      本文标题:RabbitMQ备注

      本文链接:https://www.haomeiwen.com/subject/txvdiqtx.html