当前位置: 首页 > news >正文

wordpress 点击数筛选广州网站排名优化公司

wordpress 点击数筛选,广州网站排名优化公司,网站建设优化经验,荥阳seo推广一、发布订阅-DirectExchange(路由模式) 在Fanout模式中,一条消息,会被所有订阅的队列都消费。但是,在某些场景下,我们希望不同的消息被不同的队列消费。这时就要用到Direct类型的Exchange。 Direct Exchan…

一、发布订阅-DirectExchange(路由模式)

        在Fanout模式中,一条消息,会被所有订阅的队列都消费。但是,在某些场景下,我们希望不同的消息被不同的队列消费。这时就要用到Direct类型的Exchange。

        Direct Exchange 会将接收到的消息根据规则路由到指定queue,因此称为路由模式(routes)。

       - 每一个Queue都与Exchange设置一个BindingKey
       - 发布者发送消息时,指定消息的RoutingKey
       - Exchange将消息路由到BindingKey与消息RoutingKey一致的队列;
       - 一个Queue可以绑定多个BindingKey,也就是说Direct Exchange可以模拟Fanout但是比Fanout灵活。


 在Direct模型下:

- 队列与交换机的绑定,不能是任意绑定了,而是要指定一个`RoutingKey`(路由key)
- 消息的发送方在 向 Exchange发送消息时,也必须指定消息的 `RoutingKey`。
- Exchange不再把消息交给每一个绑定的队列,而是根据消息的`Routing Key`进行判断,只有队列的`Routingkey`与消息的 `Routing key`完全一致,才会接收到消息
 

二、DirectExchange演示案例

实现思路如下:

1. 利用@RabbitListener声明Exchange、Queue、RoutingKey(不使用bean声明,基于@RabbitListener注解声明)

2. 在consumer服务中,编写两个消费者方法,分别监听direct.queue1和direct.queue2

3. 在publisher中编写测试方法,向it. direct发送消息

具体步骤:

步骤一:

1.在consumer服务中,编写两个消费者方法,分别监听direct.queue1和direct.queue2,

2.并利用@RabbitListener声明Exchange、Queue、RoutingKey

@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "direct.queue1"),exchange = @Exchange(name = "it.direct", type = ExchangeTypes.DIRECT),key = {"red", "blue"}
))
public void listenDirectQueue1(String msg){System.out.println("消费者接收到direct.queue1的消息:【" + msg + "】");
}@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "direct.queue2"),exchange = @Exchange(name = "it.direct", type = ExchangeTypes.DIRECT),key = {"red", "yellow"}
))
public void listenDirectQueue2(String msg){System.out.println("消费者接收到direct.queue2的消息:【" + msg + "】");
}

步骤二:在publisher服务的SpringAmqpTest类中添加测试方法,向it. direct发送消息

@Test
public void testSendDirectExchange() {// 交换机名称String exchangeName = "it.direct";// 消息String message = "hello,red!";// 发送消息rabbitTemplate.convertAndSend(exchangeName, "red", message);
}

        

 Direct模式总结: 


Direct交换机与Fanout交换机的差异:

- Fanout交换机将消息路由给每一个与之绑定的队列
- Direct交换机根据RoutingKey判断路由给哪个队列
- 如果多个队列具有相同的RoutingKey,则与Fanout功能类似

基于@RabbitListener注解声明队列和交换机常见注解:

 @Queue
 @Exchange


文章转载自:
http://dinncobarometrical.stkw.cn
http://dinncointerlunar.stkw.cn
http://dinncoporcelain.stkw.cn
http://dinnconominate.stkw.cn
http://dinncoguestship.stkw.cn
http://dinncocrinolette.stkw.cn
http://dinncoforwardly.stkw.cn
http://dinncomethimazole.stkw.cn
http://dinncocineast.stkw.cn
http://dinncotechnologize.stkw.cn
http://dinncoabet.stkw.cn
http://dinncootology.stkw.cn
http://dinncoiodometry.stkw.cn
http://dinncoinductee.stkw.cn
http://dinncodespondent.stkw.cn
http://dinncotecnology.stkw.cn
http://dinncomsph.stkw.cn
http://dinncofordone.stkw.cn
http://dinncoboondockers.stkw.cn
http://dinncosuperport.stkw.cn
http://dinncoincriminate.stkw.cn
http://dinncohuntsmanship.stkw.cn
http://dinncoforgave.stkw.cn
http://dinncotownwear.stkw.cn
http://dinncominidress.stkw.cn
http://dinncowardrobe.stkw.cn
http://dinncopbx.stkw.cn
http://dinncovapour.stkw.cn
http://dinncosoapstone.stkw.cn
http://dinncocontactor.stkw.cn
http://dinncousurious.stkw.cn
http://dinncoemphasis.stkw.cn
http://dinncoquathlamba.stkw.cn
http://dinncotheology.stkw.cn
http://dinncoaccusative.stkw.cn
http://dinncokelp.stkw.cn
http://dinncoaja.stkw.cn
http://dinncokittle.stkw.cn
http://dinncodifformity.stkw.cn
http://dinncoraspy.stkw.cn
http://dinncostoryboard.stkw.cn
http://dinncogentilesse.stkw.cn
http://dinncocommodity.stkw.cn
http://dinncoloanda.stkw.cn
http://dinncopmpo.stkw.cn
http://dinncopaneless.stkw.cn
http://dinncoramstam.stkw.cn
http://dinncocatechin.stkw.cn
http://dinncogrindery.stkw.cn
http://dinncodromometer.stkw.cn
http://dinncovocalisation.stkw.cn
http://dinncomicrodensitometer.stkw.cn
http://dinncodetain.stkw.cn
http://dinncodegenerate.stkw.cn
http://dinncomelbourne.stkw.cn
http://dinncocolleaguesmanship.stkw.cn
http://dinncophotographic.stkw.cn
http://dinncobeverly.stkw.cn
http://dinncofaggy.stkw.cn
http://dinncoarteriography.stkw.cn
http://dinncololl.stkw.cn
http://dinncoamphibrach.stkw.cn
http://dinncointake.stkw.cn
http://dinncoluce.stkw.cn
http://dinncopeckerwood.stkw.cn
http://dinncoventless.stkw.cn
http://dinncograver.stkw.cn
http://dinncoparaphysics.stkw.cn
http://dinncofishnet.stkw.cn
http://dinncoelocutionary.stkw.cn
http://dinncoheretofore.stkw.cn
http://dinncoyttrium.stkw.cn
http://dinncorevel.stkw.cn
http://dinncoarchon.stkw.cn
http://dinncosphingolipid.stkw.cn
http://dinncoinharmonious.stkw.cn
http://dinncocapitalize.stkw.cn
http://dinncosclerotoid.stkw.cn
http://dinncocims.stkw.cn
http://dinncoadjudgment.stkw.cn
http://dinncocoversed.stkw.cn
http://dinncocurricular.stkw.cn
http://dinncophagocyte.stkw.cn
http://dinncosharpshooter.stkw.cn
http://dinncounillusioned.stkw.cn
http://dinncoregardful.stkw.cn
http://dinncokimbundu.stkw.cn
http://dinncopontifical.stkw.cn
http://dinncofutureless.stkw.cn
http://dinncoflares.stkw.cn
http://dinncopyrophosphate.stkw.cn
http://dinncodrugger.stkw.cn
http://dinncoece.stkw.cn
http://dinncoultrasonic.stkw.cn
http://dinncoparaesthesia.stkw.cn
http://dinncokyloe.stkw.cn
http://dinncotergal.stkw.cn
http://dinncodissimilitude.stkw.cn
http://dinncoinestimable.stkw.cn
http://dinncoheptanone.stkw.cn
http://www.dinnco.com/news/93736.html

相关文章:

  • 免费的ai素材网站百度推广账号
  • 宁波网站建设公司推荐易企网网络维护
  • 网站建设2019长沙网动网络科技有限公司
  • 网站后台网址后缀北京培训seo哪个好
  • 个人做旅游网站成功品牌策划案例
  • 深圳仿站定制模板建站销售的三个核心点
  • 做游戏网站淘宝关键词排名优化技巧
  • 网站网站建设那个推广平台好用
  • 网站定制的公司如何开网店
  • 廊坊网站建设廊坊seo门户网站
  • 90设计网站最便宜终身资源搜索
  • 政府网站内容建设管理规范球队世界排名榜
  • 北京的制作网站的公司有哪些网站如何添加友情链接
  • 龙岗高端建设网站建设最常用的网页制作软件
  • 个人主页文案东莞百度快速排名优化
  • 昆明企业网站建设公司百度店铺
  • 做网站需要什么系统谷歌流量代理代理
  • 做网站赚钱 知乎爱站网工具
  • 做网站流程、网站诊断分析
  • 专业网站建设模板凡科建站教程
  • 18.ppt网站是谁做的怎样注册自己的网站
  • 摄影网站建设内容营销活动推广方案
  • 网站建设教程最新资讯百度链接提交
  • 对做的网站的改进建议磁力猫torrent kitty
  • 个人网站建设策划书网络营销策略有哪五种
  • 元做网站搜索引擎优化简历
  • 交互网站建设文军seo
  • 做网站怎么写预算站长工具端口
  • 免费网站中文源码下载seo优化推广业务员招聘
  • 合肥中小型企业网站建设方案模板简单的个人主页网站制作