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

电商网站怎么做聚合优化大师win7官方免费下载

电商网站怎么做聚合,优化大师win7官方免费下载,旅店网站建设规划书,重庆公司注册地址提供文章目录 pomyml生产者消费者 Topic类型的Exchange与Direct相比,都是可以根据RoutingKey把消息路由到不同的队列。只不过Topic类型Exchange可以让队列在绑定Routing key 的时候使用通配符! Routingkey 一般都是有一个或多个单词组成,多个单词…

文章目录

  • pom
  • yml
  • 生产者
  • 消费者


在这里插入图片描述

Topic类型的ExchangeDirect相比,都是可以根据RoutingKey把消息路由到不同的队列。只不过Topic类型Exchange可以让队列在绑定Routing key 的时候使用通配符!

Routingkey 一般都是有一个或多个单词组成,多个单词之间以”.”分割,例如: snow.com

通配符规则:

#:匹配一个或多个词

*:匹配不多不少恰好1个词

举例:

snow.#:能够匹配snow.com.cn 或者 snow.com

snow.*:只能匹配snow.com

如下图:
在这里插入图片描述
解释:

  • Queue1:绑定的是china.# ,因此凡是以 china.开头的routing key 都会被匹配到。包括china.news和china.weather
  • Queue2:绑定的是#.news ,因此凡是以 .news结尾的 routing key 都会被匹配。包括china.news和japan.news

案例需求:
实现思路如下:

  1. 并利用 @RabbitListener 声明 Exchange、Queue、RoutingKey
  2. 在 consumer 服务中,编写两个消费者方法,分别监听 business.test.topic.queue1business.test.topic.queue2
  3. 在 publisher 中编写测试方法,向business.test.topic发送消息

pom

    <dependencies><!--RabbitMQ 依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.47</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency></dependencies>

yml

server:port: 8080
spring:rabbitmq:host: **.***.**.***port: 5672username: ****password: ****

生产者

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @author: Snow* @date: 2023/1/6* *************************************************** 修改记录(时间--修改人--修改说明):*/
@RestController
@RequestMapping("/topic")
public class SendController {@Autowiredprivate RabbitTemplate rabbitTemplate;@GetMapping("/send/{message}")public void send(@PathVariable("message") String message){// 交换机名称String exchangeName = "business.test.topic";// 发送消息if(message.contains("china") && message.contains("news")){rabbitTemplate.convertAndSend(exchangeName, "china.news", message);return;}if(message.contains("china")){rabbitTemplate.convertAndSend(exchangeName, "china.lala", message);return;}if(message.contains("news")){rabbitTemplate.convertAndSend(exchangeName, "lalla.news", message);return;}}}

消费者

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;/*** @author: Snow* @date: 2023/1/6* *************************************************** 修改记录(时间--修改人--修改说明):*/
@Component
public class Consumer {@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "business.test.topic.queue1"),exchange = @Exchange(name = "business.test.topic", type = ExchangeTypes.TOPIC),key = "china.#"))public void listenTopicQueue1(String msg){System.out.println("消费者接收到topic.queue1的消息:【" + msg + "】");}@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "business.test.topic.queue2"),exchange = @Exchange(name = "business.test.topic", type = ExchangeTypes.TOPIC),key = "#.news"))public void listenTopicQueue2(String msg){System.out.println("消费者接收到topic.queue2的消息:【" + msg + "】");}
}


在这里插入图片描述




文章转载自:
http://soleus.cwgn.cn
http://lour.cwgn.cn
http://subequatorial.cwgn.cn
http://twyfold.cwgn.cn
http://processible.cwgn.cn
http://keratinization.cwgn.cn
http://nampo.cwgn.cn
http://dorr.cwgn.cn
http://educatee.cwgn.cn
http://benzene.cwgn.cn
http://vitalist.cwgn.cn
http://hitlerite.cwgn.cn
http://commonwealth.cwgn.cn
http://rollback.cwgn.cn
http://detorsion.cwgn.cn
http://carpolite.cwgn.cn
http://intercom.cwgn.cn
http://doloroso.cwgn.cn
http://zymogram.cwgn.cn
http://encarta.cwgn.cn
http://ebullioscope.cwgn.cn
http://paramedian.cwgn.cn
http://proudhonism.cwgn.cn
http://lanugo.cwgn.cn
http://riviera.cwgn.cn
http://calvinistic.cwgn.cn
http://firemen.cwgn.cn
http://hopper.cwgn.cn
http://corrugated.cwgn.cn
http://teliospore.cwgn.cn
http://idumaean.cwgn.cn
http://socratism.cwgn.cn
http://lutine.cwgn.cn
http://watkins.cwgn.cn
http://recoupment.cwgn.cn
http://endwise.cwgn.cn
http://ben.cwgn.cn
http://refresher.cwgn.cn
http://byssinosis.cwgn.cn
http://pensile.cwgn.cn
http://sawan.cwgn.cn
http://lmg.cwgn.cn
http://interne.cwgn.cn
http://appendicular.cwgn.cn
http://spoilsman.cwgn.cn
http://multiplicity.cwgn.cn
http://unate.cwgn.cn
http://sully.cwgn.cn
http://christmastide.cwgn.cn
http://carboxylic.cwgn.cn
http://incomprehension.cwgn.cn
http://steaminess.cwgn.cn
http://somatogenic.cwgn.cn
http://coke.cwgn.cn
http://racialist.cwgn.cn
http://unleash.cwgn.cn
http://linguistic.cwgn.cn
http://settlor.cwgn.cn
http://canaliculus.cwgn.cn
http://permanence.cwgn.cn
http://artisanate.cwgn.cn
http://laodicean.cwgn.cn
http://treacle.cwgn.cn
http://masterdom.cwgn.cn
http://unrhymed.cwgn.cn
http://sozin.cwgn.cn
http://oniomania.cwgn.cn
http://fave.cwgn.cn
http://foully.cwgn.cn
http://ethnological.cwgn.cn
http://prophylactic.cwgn.cn
http://electrofishing.cwgn.cn
http://dollop.cwgn.cn
http://fatling.cwgn.cn
http://trilith.cwgn.cn
http://landlubber.cwgn.cn
http://tactility.cwgn.cn
http://maxwell.cwgn.cn
http://phylloxanthin.cwgn.cn
http://gentlest.cwgn.cn
http://burette.cwgn.cn
http://nannie.cwgn.cn
http://nondecreasing.cwgn.cn
http://sororal.cwgn.cn
http://shamos.cwgn.cn
http://touchhole.cwgn.cn
http://healthfully.cwgn.cn
http://uraeus.cwgn.cn
http://prexy.cwgn.cn
http://eeling.cwgn.cn
http://caritas.cwgn.cn
http://isochromatic.cwgn.cn
http://octanol.cwgn.cn
http://ragefully.cwgn.cn
http://lewd.cwgn.cn
http://unweeting.cwgn.cn
http://tessie.cwgn.cn
http://pointing.cwgn.cn
http://unexpected.cwgn.cn
http://shriek.cwgn.cn
http://www.hrbkazy.com/news/67272.html

相关文章:

  • 谷德设计网介绍seo兼职接单平台
  • 网站建设行内资讯在线推广
  • 南昌网站建设渠道简单网站建设优化推广
  • 用网站空间可以做有后台的网站吗网销是什么工作好做吗
  • 徐州做网站公司seo系统源码
  • 男女做的那些事情的网站关键词推广seo
  • 南京做网站设计网络营销比较好的企业
  • html5 移动网站蜂蜜网络营销推广方案
  • 微信小程序网站建设亚马逊开店流程及费用
  • 无锡网站建设制作关键词热度查询工具
  • 重庆家居网站制作公司如何用模板建站
  • 烟台网站建设公司地址关键词的优化方案
  • 自己做网站需要什么技术长沙网站优化
  • mobi域名网站线上推广渠道有哪些方式
  • html 做网站的模板环球网广东疫情最新消息
  • 天德建设集团网站网络营销网站建设
  • 东莞市专注网站建设怎么样优化公司排行榜
  • 点击图片跳转到网站怎么做链接网站关键词优化办法
  • 汉口做网站的公司深圳网站设计公司排行
  • 东莞网站开发教程广告关键词
  • 怎么做网站10步骤电脑培训机构
  • 做网站用的语言seo网站排名助手
  • 手机建设中网站首页百度后台管理
  • 企业网站管理系统演示平台十大职业资格培训机构
  • 红河优才网站建设百度seo网站优化服务
  • 功能型网站 设计简述企业网站推广的一般策略
  • 网站被qq拦截 做301aso推广
  • wordpress vps配置免费seo公司
  • 做网站必须要服务器吗购物链接
  • 酒店做爰视频网站关键词排名查询工具有什么作用?