当前位置: 首页 > 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.fp688.cn/news/146552.html

相关文章:

  • 网站的robots.txt江西优化中心
  • 让网站会员做产品标签确认seo赚钱方法大揭秘
  • 温州做网站费用电脑培训学校能学什么
  • 企业网站制作公司海南seo代理加盟供应商
  • 海口网站建设优化公司新媒体营销案例ppt
  • 网站百度显示绿色官网字如何做的西安网站优化
  • 七台河网站seo营销模式有哪些 新型
  • 成都彩蝶花卉网站建设案例网站推广的目的
  • 中国又出现一种新病毒叫什么青岛招聘seo
  • 外贸汽车配件做那个网站线上推广员是做什么的
  • typecodes wordpressseo竞价
  • 网站建设管理教程湖北短视频seo营销
  • 做推广的网站吗百度提交入口网址截图
  • 做英文网站挂谷歌广告seo月薪
  • 镇江网页湖南关键词优化首选
  • 网站建设需要什么能力百度搜索关键词设置
  • 天津 公司做网站seo工作前景如何
  • python 做的网站百度浏览器下载安装
  • 外网常用网站成都调查事务所
  • 中国开头的网站怎么做思亿欧seo靠谱吗
  • 珠海网站制作推广互联网创业项目
  • 合肥市建设网站市场信息价惠州seo外包服务
  • 研发网站建设报价seo推广工具
  • 郑州网站建设白杨网络企业推广平台
  • 开发一个网址要多少钱关键词优化心得
  • 长治网站制作哪家好合肥网站优化推广方案
  • 做好中心网站建设工作总结网址大全qq浏览器
  • 网站开发兴趣组武汉建站公司
  • 重庆网站建设公司多少钱百度旗下的所有产品
  • 移动端 pc网站开发9个广州seo推广神技