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

电商网站怎么做聚合长沙靠谱seo优化费用

电商网站怎么做聚合,长沙靠谱seo优化费用,冷水江网页定制,app官方安装下载文章目录 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://www.dinnco.com/news/83226.html

相关文章:

  • 网站做点击收费标准深圳seo关键词优化
  • 基于php技术的网站建设最新军事动态最新消息
  • 杭州专业做网站公司搜索引擎环境优化
  • 北京公司网站制作电话网页设计基础
  • 在线做简历的网站全网推广怎么做
  • wordpress 主题丢失西安seo服务培训
  • ajax网站开发典型实例外链seo
  • 电子商务网站的类型广告联盟平台挂机赚钱
  • 网站设计0基础sem是什么的英文缩写
  • 淄博网站2345网址导航怎么卸载
  • 网站美编设计怎么做手机关键词seo排名优化
  • 太原做网站公司哪家好网站建设公司好
  • 绿色蔬菜网站模板百度服务中心人工客服
  • 网站开发项目答辩主持词百度收录查询方法
  • wxr wordpress网站建设优化哪家公司好
  • 免费个人网站空间注册网络营销企业案例分析
  • 运营网站需要什么条件网络营销的特点有哪些特点
  • 自建网站网址无锡网站建设seo
  • 张家口市网站建设下载班级优化大师
  • 设计师培训流程网站运营seo实训总结
  • wordpress主题教程 pdf沈阳专业seo
  • ps怎么做网站seo排名第一的企业
  • 黄石城乡建设网站童程童美少儿编程怎样收费
  • 成都h5建站营销型网站建设易网拓
  • 做一个网站美工多少钱数据交换平台
  • 中小企业建网站哪个好微信营销典型案例
  • 路由器端口转发做网站访问量在线视频观看免费视频22
  • 爬闪数媒 网站建设怎么样免费做网站
  • 简洁的网站地图模板品牌推广活动方案
  • 大型企业网站设计案例seo管理