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

武汉专业网站做网页精准营销理论

武汉专业网站做网页,精准营销理论,有什么网站建设比较好的公司,网络营销总监岗位职责发布订阅模型: MQ提供了很多交换机模型 其中常用的有下边三个: Fanout:广播 Direct:路由 Topic:话题 转换器只负责消息路由,不是存储,路由失败则消息丢失 Fanout Exchange:会将接收到的消息路由导每一个跟其绑定的queue. 利用SpringAMQP演示Fanout…

发布订阅模型:

MQ提供了很多交换机模型 其中常用的有下边三个:

Fanout:广播

Direct:路由

Topic:话题

转换器只负责消息路由,不是存储,路由失败则消息丢失

Fanout Exchange:会将接收到的消息路由导每一个跟其绑定的queue.

利用SpringAMQP演示FanoutExchange的使用:

实现代码:

在consumer编写工具类,实现交换机和队列的绑定:

package cn.itcast.mq.configu;import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** @className:cn.itcast.mq.configu.BindExchangeToQueue* @description:by-li* @author:Administrator* @create:2024-05-1116:33*/
@Configuration
public class BindExchangeToQueue {//声明交换机@Beanpublic FanoutExchange fanoutExchange() {return new FanoutExchange("itcast.fanout");}//生命queue@Beanpublic Queue fanoutqueue1() {return new Queue("itcast.queue1");}@Beanpublic Queue fanoutqueue2() {return new Queue("itcast.queue2");}//绑定交换机@Beanpublic Binding fanoutExchangeToQueue1Bind(Queue fanoutqueue1, FanoutExchange fanoutExchange){return BindingBuilder.bind(fanoutqueue1).to(fanoutExchange);//绑定交换机和队列}@Beanpublic Binding fanoutExchangeToQueue2Bind(Queue fanoutqueue2, FanoutExchange fanoutExchange){return BindingBuilder.bind(fanoutqueue2).to(fanoutExchange);//绑定交换机和队列}}

在consumer实体类里编写接收两个队列请求的方法:

    @RabbitListener(queues = "itcast.queue1")public void lintestFanoutExchangeToQueue1(String mes) throws InterruptedException {System.out.println("从队列1中获取到了消息:"+mes);Thread.sleep(200);}@RabbitListener(queues = "itcast.queue2")public void lintestFanoutExchangeToQueue2(String mes) throws InterruptedException {System.out.println("从队列2中获取到了消息:"+mes);Thread.sleep(200);}

在publisher里编写测试方法 模拟给交换机发送消息:

//给FanoutExchange交换机发送消息@Testpublic void testFanoutExchangeSend(){String FanoutChangeName = "itcast.fanout";String msg="我是fannout发送的消息";rabbitTemplate.convertAndSend(FanoutChangeName,"",msg);}

然后发送请求和启动consumer类,在控制台查看:

这里看到我们只发送了一条消息,但是两个consumer消费者都接收到了消息,能看出来Fanout Exchange交换机将收到的消息发到了给他绑定的两个queue里了

总结:

http://www.mmbaike.com/news/28249.html

相关文章:

  • 大型商家进驻网站开发百度关键词购买
  • 做网站怎么选择服务器的大小正规赚佣金的平台
  • 2024最火游戏排行榜杭州网站排名seo
  • 交友网站怎么做鄞州seo整站优化服务
  • 网站设计 做鼠标效果苏州百度推广代理商
  • 个人网站做电影网站北京疫情最新数据
  • 外贸b2b平台网站seo关键词查询排名软件
  • 专业建设外贸网站制作百度排行榜前十名
  • wix和wordpress天津百度seo排名优化软件
  • 区域信息网站怎么做长沙网站优化
  • 怎么开通微信小程序商店seo网站优化多少钱
  • 什么网站可以做兼职 知乎凡科建站收费价目表
  • 做php网站会员开店代码如何编写网络营销公司哪家好
  • 网站的费用可以做无形资产吗建网站赚钱
  • 百度做任务的网站开发做一个网站需要多少钱
  • 自己建立网站怎么搞石家庄最新新闻事件
  • 重庆网站推广解决方案网页设计师
  • 宁波妇科中医哪个好湖南seo技术培训
  • 上海最专业的网站设计制太原最新情况
  • 群晖nas做网站性能上海疫情突然消失的原因
  • 做课件赚钱网站在哪里前端seo是什么
  • 自己做的网站怎么维护黄冈网站推广策略
  • 做网站与运营一般多少钱如何创建一个网址
  • 双桥区网站制作百度云网页版登录入口
  • 大朗镇住房规划建设局网站北京推广优化经理
  • wordpress热门文章代码萌新seo
  • 莒县做网站的公司推广策划方案模板
  • 怎么还原wordpress网络优化大师
  • 怎么在社保网站上做员工减少深圳网页设计公司
  • 广州网站推广服务网站建设报价单模板