基于EasyNetQ操作RabbitMQ的Demo项目

基于EasyNetQ操作RabbitMQ的Demo项目


介绍

RabbitMQ是一个由erlang开发的基于AMQP(Advanced Message Queue)协议的开源实现。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面都非常的优秀。是当前最主流的消息中间件之一。

RabbitMQ的官方

image

  • 概念:
    • Brocker:消息队列服务器实体。
    • Exchange:消息交换机,指定消息按什么规则,路由到哪个队列。
    • Queue:消息队列,每个消息都会被投入到一个或者多个队列里。
    • Binding:绑定,它的作用是把exchange和queue按照路由规则binding起来。
    • Routing Key:路由关键字,exchange根据这个关键字进行消息投递。
    • Vhost:虚拟主机,一个broker里可以开设多个vhost,用作不用用户的权限分离。
    • Producer:消息生产者,就是投递消息的程序。
    • Consumer:消息消费者,就是接受消息的程序。
    • Channel:消息通道,在客户端的每个连接里,可建立多个channel,每个channel代表一个会话任务。
  • 消息队列的使用过程大概如下:
    • 消息接收
      • 客户端连接到消息队列服务器,打开一个channel。
      • 客户端声明一个exchange,并设置相关属性。
      • 客户端声明一个queue,并设置相关属性。
      • 客户端使用routing key,在exchange和queue之间建立好绑定关系。
    • 消息发布
      • 客户端投递消息到exchange。
      • exchange接收到消息后,就根据消息的key和已经设置的binding,进行消息路由,将消息投递到一个或多个队列里。
  • AMQP 里主要要说两个组件:
    • Exchange 和 Queue
    • 绿色的 X 就是 Exchange ,红色的是 Queue ,这两者都在 Server 端,又称作 Broker
    • 这部分是 RabbitMQ 实现的,而蓝色的则是客户端,通常有 Producer 和 Consumer 两种类型。
  • Exchange通常分为四种:
    • fanout:该类型路由规则非常简单,会把所有发送到该Exchange的消息路由到所有与它绑定的Queue中,相当于广播功能
    • direct:该类型路由规则会将消息路由到binding key与routing key完全匹配的Queue中
    • topic:与direct类型相似,只是规则没有那么严格,可以模糊匹配和多条件匹配
    • headers:该类型不依赖于routing key与binding key的匹配规则来路由消息,而是根据发送的消息内容中的headers属性进行匹配
  • https://github.com/SFLAQiu/RabbitMQDemo

博文最后更新时间:


评论

  • Merziuz

    ydv45Y http://pills2sale.com/ viagra online

  • Elisha

    Whereabouts are you from? <a href="http://www.atozfruitsandveg.com/levitra-canada-price-v5so">comprar levitra generico online</a> North Korea said the six days of reunions, which last happened three years ago, could not be held because of South Korean conservatives' "reckless and vicious confrontation racket" against Pyongyang, a claim that North Korea routinely makes. It also vowed, in similarly familiar rhetoric, to "take strong and decisive counteractions against the South Korean puppet regime's ever-escalating war provocations."

  • Marcel

    Would you like to leave a message? <a href="https://www.electronicautomovil.es/purchase-bactrim-ds-rf7c">bactrim generic</a> Bargnani, the No. 1 overall selection in 2006, has the size and skills set that make NBA scouts fall over themselves. In a league where 3-point shooting is at a premium, Bargnani is a big with three-point range. He fits perfectly with the Knicks, who are looking for players to complement Carmelo Anthony. Bargnani’s presence means more space on the floor for Anthony to operate.

  • Genesis

    I've got a part-time job <a href="http://adena.ro/v2/avelox-antybiotyk-cena-od59">avelox oral dosage</a> While travel insurance can't prevent tragedies such as the one that unfolded Saturday when an Asiana Airlines flight crash-landed at the San Francisco International Airport, it can ease the pain of far more common inconveniences. Travel insurance typically covers the cost of trip interruptions and cancellations, loss of luggage and transportation to medical facilities in the event of an accident. However, your homeowners or auto insurance may already cover a lot of these extra expenses. Make sure you're not buying travel insurance for coverage you already have.

  • Cliff

    What part of do you come from? <a href="https://malkostau.lt/clobetasol-locin-capilar-para-que-sirve-mrc6">does clobetasol propionate treat ringworm</a> Lawyers for Unitech also argued that Unitech would have expected to be informed by Deutsche Bank of attempted Libor manipulation by banks and that its failure to do so counted as an "implied misrepresentation" which gave Unitech the right to rescind the agreement.

  • Kayla

    Have you got any qualifications? <a href="https://aiksourcing.com.my/mizon-all-in-one-snail-repair-cream-reddit-20tm">mizon all in one snail repair cream reddit </a> Sir Michael, previously head of Mossbourne academy in Hackney, added: “I am putting my headteacher hat on. I was concerned when children left the front gates and too often went to the wrong sorts of places which run counter to the culture we tried to introduce.

发表评论

博客统计

访问量:5264024

博文总数:750 评论总数:910100

原创126 翻译20 转载604