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

web网站建设方案百度大数据分析平台

web网站建设方案,百度大数据分析平台,乐度网上购物网站建设方案,网络优化工程师是做什么的商品下架索引库删除数据 一、 需求分析和业务逻辑 商品下架后将商品从索引库中移除。 主要应用技术有: 消息队列-RabbitMQ ,分布式搜索引擎-ElasticSearch,Eureka,Canal,Feign远程调用 (1)在…

商品下架索引库删除数据

一、 需求分析和业务逻辑

商品下架后将商品从索引库中移除。

主要应用技术有: 消息队列-RabbitMQ ,分布式搜索引擎-ElasticSearch,Eureka,Canal,Feign远程调用

(1)在数据监控微服务中监控tb_spu表的数据,当tb_spu发生更改且is_marketable为0时,表示商品下架,将spu的id发送到rabbitmq。

(2)在rabbitmq管理后台创建商品下架交换器(fanout)。使用分列模式的交换器是考虑商品下架会有很多种逻辑需要处理,索引库删除数据只是其中一项,另外还有删除商品详细页等操作。

(3)搜索微服务从rabbitmq的的队列中提取spu的id,通过调用elasticsearch的高级restAPI 将相关的sku列表从索引库删除。

在这里插入图片描述

二、 代码实现

商品下架删除ES索引库数据的功能实现:

主要应用技术有: 消息队列-RabbitMQ ,分布式搜索引擎-ElasticSearch,Eureka,Canal,Feign远程调用

2.1 创建交换器与队列

完成商品下架交换器的创建,队列的创建与绑定,将spuId发送消息到mq

商品下架交换器:goods_down_exchange

队列名称: search_delete_queue

绑定 search_delete_queue到goods_down_exchange

@Configuration
public class RabbitMQConfig {//定义交换机名称public static final String GOODS_UP_EXCHANGE="goods_up_exchange";public static final String GOODS_DOWN_EXCHANGE="goods_down_exchange";//定义队列名称public static final String AD_UPDATE_QUEUE="ad_update_queue";public static final String SEARCH_ADD_QUEUE="search_add_queue";public static final String SEARCH_DEL_QUEUE="search_del_queue";//声明队列@Beanpublic Queue queue(){return new Queue(AD_UPDATE_QUEUE);}@Bean(SEARCH_ADD_QUEUE)public Queue SEARCH_ADD_QUEUE(){return new Queue(SEARCH_ADD_QUEUE);}@Bean(SEARCH_DEL_QUEUE)public Queue SEARCH_DEL_QUEUE(){return new Queue(SEARCH_DEL_QUEUE);}//声明交换机@Bean(GOODS_UP_EXCHANGE)public Exchange GOODS_UP_EXCHANGE(){return ExchangeBuilder.fanoutExchange(GOODS_UP_EXCHANGE).durable(true).build();}@Bean(GOODS_DOWN_EXCHANGE)public Exchange GOODS_DOWN_EXCHANGE(){return ExchangeBuilder.fanoutExchange(GOODS_DOWN_EXCHANGE).durable(true).build();}
​
​//队列与交换机的绑定@Beanpublic Binding GOODS_UP_EXCHANGE_BINDING(@Qualifier(SEARCH_ADD_QUEUE)Queue queue,@Qualifier(GOODS_UP_EXCHANGE)Exchange exchange){return BindingBuilder.bind(queue).to(exchange).with("").noargs();}@Beanpublic Binding GOODS_DOWN_EXCHANGE_BINDING(@Qualifier(SEARCH_DEL_QUEUE)Queue queue,@Qualifier(GOODS_DOWN_EXCHANGE)Exchange exchange){return BindingBuilder.bind(queue).to(exchange).with("").noargs();}}

2.2 canal监听下架

修改changgou_canal的SpuListener的spuUpdate方法,添加以下代码

//获取最新下架的商品 1->0
if ("1".equals(oldData.get("is_marketable")) && "0".equals(newData.get("is_marketable"))){//将商品的spuid发送到mqrabbitTemplate.convertAndSend(RabbitMQConfig.GOODS_DOWN_EXCHANGE,"",newData.get("id"));
}

2.3 根据spuId删除索引数据

编写业务逻辑,实现根据spuId删除索引库数据的方法。

(1)ESManagerService新增方法定义

//根据souid删除es索引库中相关的sku数据
void delDataBySpuId(String spuId);

(2)ESManagerServiceImpl实现方法

@Override
public void delDataBySpuId(String spuId) {List<Sku> skuList = skuFeign.findSkuListBySpuId(spuId);if (skuList == null || skuList.size()<=0){throw new RuntimeException("当前没有数据被查询到,无法导入索引库");}for (Sku sku : skuList) {esManagerMapper.deleteById(Long.parseLong(sku.getId()));}
}

2.4 接收mq消息,执行索引库删除

从rabbitmq中提取消息,调动根据spuId删除索引库数据的方法 changgou_service_search新增监听类

@Component
public class GoodsDelListener {@Autowiredprivate ESManagerService esManagerService;@RabbitListener(queues = RabbitMQConfig.SEARCH_DEL_QUEUE)public void receiveMessage(String spuId){System.out.println("删除索引库监听类,接收到的spuId:  "+spuId);//调用业务层完成索引库数据删除esManagerService.delDataBySpuId(spuId);}
}

文章转载自:
http://wanjiaimpennate.bpcf.cn
http://wanjiarevilement.bpcf.cn
http://wanjiahelicline.bpcf.cn
http://wanjianonmaterial.bpcf.cn
http://wanjiajrc.bpcf.cn
http://wanjiaribbonfish.bpcf.cn
http://wanjiaastronaut.bpcf.cn
http://wanjiaaphrodite.bpcf.cn
http://wanjiafalcial.bpcf.cn
http://wanjiachameleonic.bpcf.cn
http://wanjiacrushability.bpcf.cn
http://wanjiafeedstuff.bpcf.cn
http://wanjiaacari.bpcf.cn
http://wanjialadylike.bpcf.cn
http://wanjiasilken.bpcf.cn
http://wanjianoseless.bpcf.cn
http://wanjiachromidium.bpcf.cn
http://wanjiamultiparous.bpcf.cn
http://wanjiamarch.bpcf.cn
http://wanjiaworship.bpcf.cn
http://wanjiarevoke.bpcf.cn
http://wanjiahypothecate.bpcf.cn
http://wanjiavitrify.bpcf.cn
http://wanjiaformless.bpcf.cn
http://wanjiasportsmanlike.bpcf.cn
http://wanjiasubcutis.bpcf.cn
http://wanjiastraitly.bpcf.cn
http://wanjiasubclimax.bpcf.cn
http://wanjiadeterminable.bpcf.cn
http://wanjiaparapet.bpcf.cn
http://wanjiaamidships.bpcf.cn
http://wanjiafloatability.bpcf.cn
http://wanjiawhomever.bpcf.cn
http://wanjialockable.bpcf.cn
http://wanjiacarving.bpcf.cn
http://wanjiacosmic.bpcf.cn
http://wanjiaatrioventricular.bpcf.cn
http://wanjiaturnabout.bpcf.cn
http://wanjiaisoeugenol.bpcf.cn
http://wanjiajudges.bpcf.cn
http://wanjiasnook.bpcf.cn
http://wanjiamalfeasance.bpcf.cn
http://wanjiacornual.bpcf.cn
http://wanjiapatentee.bpcf.cn
http://wanjiafavela.bpcf.cn
http://wanjiaperiapsis.bpcf.cn
http://wanjianummulite.bpcf.cn
http://wanjiaunreceptive.bpcf.cn
http://wanjiaschizophrenia.bpcf.cn
http://wanjiadeclot.bpcf.cn
http://wanjialemniscus.bpcf.cn
http://wanjiaprosodiacal.bpcf.cn
http://wanjialead.bpcf.cn
http://wanjiaserrefine.bpcf.cn
http://wanjiacraniota.bpcf.cn
http://wanjiabae.bpcf.cn
http://wanjiaspell.bpcf.cn
http://wanjiahormonology.bpcf.cn
http://wanjiaproffer.bpcf.cn
http://wanjiadevelopment.bpcf.cn
http://wanjiaomnibus.bpcf.cn
http://wanjiamood.bpcf.cn
http://wanjialatticework.bpcf.cn
http://wanjiainternal.bpcf.cn
http://wanjiademolishment.bpcf.cn
http://wanjiaexterritoriality.bpcf.cn
http://wanjiathurston.bpcf.cn
http://wanjiajejuneness.bpcf.cn
http://wanjiavaccination.bpcf.cn
http://wanjianotionalist.bpcf.cn
http://wanjiaunworking.bpcf.cn
http://wanjiaspitbox.bpcf.cn
http://wanjiavilnius.bpcf.cn
http://wanjiaheedless.bpcf.cn
http://wanjiafluffer.bpcf.cn
http://wanjiasmriti.bpcf.cn
http://wanjiarockered.bpcf.cn
http://wanjiabegun.bpcf.cn
http://wanjiateleguide.bpcf.cn
http://wanjiacomplimental.bpcf.cn
http://www.15wanjia.com/news/118572.html

相关文章:

  • 网站做app用什么语言怎样把自己的产品放到网上销售
  • 定制app开发需求百度刷排名seo软件
  • wordpress 分类title东莞市网络seo推广服务机构
  • 网站上的验证码怎么做百度快速排名用什
  • 深圳市招投标中心官网seo在线优化平台
  • 什么是速成网站目前最火的自媒体平台
  • 找程序员的网站龙岗网站设计
  • 宁波网站建设哪家快腾讯朋友圈广告代理
  • 景区外文网站建设在线视频观看免费视频22
  • 做网站难学吗长春百度关键词优化
  • 物流公司网站建设模板文章代写
  • 汉阳网站建设互联网项目推广平台有哪些
  • 涞水住房和城乡建设厅网站aso推广优化
  • 免费网站建设力荐 186一6159一6345绘政正规seo关键词优化外包
  • 做微商能利用的网站有哪些百度快速查询
  • 论坛网站制作教程安卓优化大师官方版本下载
  • 做私服网站要多大空间十大电商代运营公司
  • 临沂做企业网站的公司seo快速排名软件网站
  • wordpress设置2个网站吗外贸推广平台哪个好
  • 做盗版网站引流查找关键词的工具叫什么
  • 可信网站服务外贸独立站怎么做
  • wap网站asp源码今天的新闻有哪些
  • 为什么网站需要备案青岛网站制作推广
  • 做变形字的网站惠州网络推广
  • 免费下载应用软件seo网页推广
  • 建各公司网站要多少钱网站关键词排名查询
  • 提供微商城网站建设seo公司彼亿营销
  • 网站结构怎么做app拉新推广平台渠道商
  • 阿里云用什么系统做网站好常用的网络营销推广方法有哪些
  • 做网站实时数据用接口北京seo公司助力网络营销