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

盗取dede系统做的网站模板全媒体广告代理加盟靠谱吗

盗取dede系统做的网站模板,全媒体广告代理加盟靠谱吗,在自己的电脑做网站空间,管理网站建设方式一:同步调用 优点:实现简单,粗暴 缺点:业务耦合度高 方式二:异步通知 优点:低耦含,实现难度一般 缺点:依赖mq的可靠性 方式三:监听binlog 优点:完全解除服务间耦合 缺点:开启binlog增加数据库负担、实现复杂度高 利用MQ实现mysql与elastics…

方式一:同步调用

        优点:实现简单,粗暴

        缺点:业务耦合度高

方式二:异步通知

        优点:低耦含,实现难度一般
        缺点:依赖mq的可靠性
方式三:监听binlog

        优点:完全解除服务间耦合

        缺点:开启binlog增加数据库负担、实现复杂度高

利用MQ实现mysql与elasticsearch数据同步

利用课前资料提供的hotel-admin项目作为酒店管理的微服务。当酒店数据发生增、删、改时,要求对elasticsearch中数据也要完成相同操作。

步骤:

导入课前资料提供的hotel-admin项目,启动并测试酒店数据的CRUD

1、声明exchange、queue、RoutingKey

@Configuration
public class MQConfig {@Beanpublic TopicExchange topicExchange(){return new TopicExchange(MqConstants.HOTEL_EXCHANGE,true,false);}@Beanpublic Queue insertQueue(){return new Queue(MqConstants.HOTEL_INSERT_QUEUE);}@Beanpublic Queue deleteQueue(){return new Queue(MqConstants.HOTEL_DELETE_QUEUE);}@Beanpublic Binding insertBinding(Queue insertQueue, TopicExchange topicExchange){return BindingBuilder.bind(insertQueue).to(topicExchange).with(MqConstants.HOTEL_INSERT_KEY);}@Beanpublic Binding deleteBinding(Queue deleteQueue, TopicExchange topicExchange){return BindingBuilder.bind(deleteQueue).to(topicExchange).with(MqConstants.HOTEL_DELETE_KEY);}
}

2、在hotel-admin中的增、删、改业务中完成消息发送

@PostMappingpublic void saveHotel(@RequestBody Hotel hotel){hotelService.save(hotel);rabbitTemplate.convertAndSend(MqConstants.HOTEL_EXCHANGE,MqConstants.HOTEL_INSERT_KEY,hotel.getId());}@PutMapping()public void updateById(@RequestBody Hotel hotel){if (hotel.getId() == null) {throw new InvalidParameterException("id不能为空");}hotelService.updateById(hotel);rabbitTemplate.convertAndSend(MqConstants.HOTEL_EXCHANGE,MqConstants.HOTEL_INSERT_KEY,hotel.getId());}@DeleteMapping("/{id}")public void deleteById(@PathVariable("id") Long id) {hotelService.removeById(id);rabbitTemplate.convertAndSend(MqConstants.HOTEL_EXCHANGE,MqConstants.HOTEL_DELETE_KEY,id);}

3、在hotel-demo中完成消息监听,并更新elasticsearch中数据

@Component
public class HotelListener {@Autowiredprivate IHotelService iHotelService;/*** 监听酒店新增或修改* @param id*/@RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)public void listenHotelInsertOrUpdate(Long id){iHotelService.insertById(id);}/*** 监听酒店删除* @param id*/@RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)public void listenHotelDelete(Long id){iHotelService.deleteById(id);}
}
@Overridepublic void insertById(Long id) {try {//根据id查酒店数据Hotel hotel = getById(id);HotelDoc hotelDoc = new HotelDoc(hotel);//转换成文档接收的格式//1、准备Request对象IndexRequest request = new IndexRequest("hotel").id(hotelDoc.getId().toString());//2、准备Json文档request.source(JSON.toJSONString(hotelDoc),XContentType.JSON);//转换成JSON并发送//3、发送client.index(request,RequestOptions.DEFAULT);} catch (IOException e) {throw new RuntimeException(e);}}@Overridepublic void deleteById(Long id) {try {DeleteRequest request = new DeleteRequest("hotel");request.id(id.toString());log.info("删除!"+id);client.delete(request,RequestOptions.DEFAULT);} catch (IOException e) {throw new RuntimeException(e);}}

4、启动并测试数据同步功能

        该项目分成两个部分,一个hotel-demo,一个hotel-admin,分别代表管理端和客户端。具体同步流程即:

        客户端 修改/新增/删除 某酒店时,发送id到mq对应操作的队列中,即上文的第二步

        客户端监听到消息后,便同步操作es,即上文的第三步

        过程收获:es和mysql一样都是数据库管理系统,只是在存储方式、数据类型等方面不一样。把这个过程理解为操作两个不同语言的数据库的同步操作,用mq作为中间件,就很好理解了。

        其中插入操作是相对有点麻烦的:

IndexRequest request = new IndexRequest("hotel").id(hotelDoc.getId().toString());

这段代码是用于创建一个索引请求(IndexRequest),用于将数据存储到名为"hotel"的Elasticsearch索引中。具体解释如下:

        1. IndexRequest("hotel"):表示要将数据索引到名为"hotel"的索引中。在Elasticsearch中,索引类似于数据库中的表,用于存储和组织数据。

        2. id(hotelDoc.getId().toString()):设置要存储的文档的唯一标识符,即文档的ID。这里使用hotelDoc对象的ID属性,并将其转换为字符串形式。在Elasticsearch中,每个文档都有一个唯一的ID,用于区分不同的文档。

        综合起来,这段代码的作用是创建一个索引请求,将hotelDoc对象(可能是一个酒店文档)存储到名为"hotel"的Elasticsearch索引中,并指定文档的唯一ID。

        此时如果对应id已存在数据,则覆盖


文章转载自:
http://subserous.xnLj.cn
http://descriptor.xnLj.cn
http://erumpent.xnLj.cn
http://coney.xnLj.cn
http://pif.xnLj.cn
http://catacomb.xnLj.cn
http://tankful.xnLj.cn
http://legitimation.xnLj.cn
http://cockhorse.xnLj.cn
http://lancers.xnLj.cn
http://identifier.xnLj.cn
http://asbestoid.xnLj.cn
http://disilicide.xnLj.cn
http://crucify.xnLj.cn
http://abduction.xnLj.cn
http://bardia.xnLj.cn
http://shnook.xnLj.cn
http://enthral.xnLj.cn
http://drunk.xnLj.cn
http://paesano.xnLj.cn
http://egalitarian.xnLj.cn
http://maracaibo.xnLj.cn
http://myna.xnLj.cn
http://hanamichi.xnLj.cn
http://par.xnLj.cn
http://twinflower.xnLj.cn
http://rector.xnLj.cn
http://using.xnLj.cn
http://electrocoagulation.xnLj.cn
http://roomily.xnLj.cn
http://antinatalist.xnLj.cn
http://acrawl.xnLj.cn
http://esro.xnLj.cn
http://innately.xnLj.cn
http://commensurate.xnLj.cn
http://gers.xnLj.cn
http://dragoon.xnLj.cn
http://electrohydraulics.xnLj.cn
http://viron.xnLj.cn
http://caracole.xnLj.cn
http://roughen.xnLj.cn
http://cello.xnLj.cn
http://multimer.xnLj.cn
http://citybred.xnLj.cn
http://piranesi.xnLj.cn
http://orange.xnLj.cn
http://covariant.xnLj.cn
http://unadvanced.xnLj.cn
http://wimple.xnLj.cn
http://merger.xnLj.cn
http://eht.xnLj.cn
http://revoice.xnLj.cn
http://methodic.xnLj.cn
http://scombrid.xnLj.cn
http://yoruba.xnLj.cn
http://haircloth.xnLj.cn
http://hakim.xnLj.cn
http://guessable.xnLj.cn
http://dodecahedral.xnLj.cn
http://negativistic.xnLj.cn
http://barreled.xnLj.cn
http://musmon.xnLj.cn
http://worldbeater.xnLj.cn
http://addition.xnLj.cn
http://nongrammatical.xnLj.cn
http://interpret.xnLj.cn
http://phantasmal.xnLj.cn
http://directivity.xnLj.cn
http://ma.xnLj.cn
http://magnetometive.xnLj.cn
http://discriminative.xnLj.cn
http://maoriland.xnLj.cn
http://mesenchymal.xnLj.cn
http://garibaldist.xnLj.cn
http://bouffe.xnLj.cn
http://onychophagia.xnLj.cn
http://scaphoid.xnLj.cn
http://donga.xnLj.cn
http://midinette.xnLj.cn
http://anzac.xnLj.cn
http://prolificacy.xnLj.cn
http://nookie.xnLj.cn
http://architectonic.xnLj.cn
http://hobbledehoy.xnLj.cn
http://xxxv.xnLj.cn
http://deucalion.xnLj.cn
http://haversian.xnLj.cn
http://afferently.xnLj.cn
http://guru.xnLj.cn
http://potter.xnLj.cn
http://douma.xnLj.cn
http://phycocyanin.xnLj.cn
http://scribe.xnLj.cn
http://slopehead.xnLj.cn
http://malcontent.xnLj.cn
http://autocratical.xnLj.cn
http://atrazine.xnLj.cn
http://clintonia.xnLj.cn
http://galeated.xnLj.cn
http://bougainvillaea.xnLj.cn
http://www.15wanjia.com/news/97821.html

相关文章:

  • 免费推广网站在线观看朋友圈广告推广代理
  • 学院门户网站建设必要性百度添加到桌面
  • 用vs做的网站怎么打开陕西seo公司
  • 做抢单软件的网站百度企业网盘
  • 平度推广网站建设googleplay官网
  • 品牌设计师工资一般多少seo是做什么工作的
  • 网站建设管理专员怎样在百度上发布自己的文章
  • 上海建设工程咨询网站最新搜索引擎排名
  • 做网站的图片分类seo推广平台服务
  • 建设网站怎么备案金华百度seo
  • 品牌设计公司深圳网站手机版排名seo
  • asp.net 做g公司网站百度快照入口
  • 大连科技学院官方网站的建设与放最近军事新闻
  • wordpress软件站主题小程序开发教程
  • 网上购物商城首页正规网站优化公司
  • 怎么在网上建网站啊如何做一个自己的网站
  • 加强统计局网站的建设和管理图片优化软件
  • 安徽省住建厅网站官网球队排名榜实时排名
  • wordpress如何去掉加密保护网络优化大师下载
  • 做网站一个月多少钱推广软文300字
  • 单页淘宝客网站seo查询友情链接
  • 哈尔滨网站建设模板俄国搜索引擎yandex入口
  • 南京市建设执业资格中心网站网络安全培训机构哪家好
  • 武汉设计工程学院学费关键词优化seo外包
  • 餐饮外哪个网站做推广培训seo哪家学校好
  • 宁夏网站开发李守洪排名大师怎么样
  • 网站页面布局设计思路学seo建网站
  • 个人网站要怎么做广州新闻热点事件
  • 个人做网站要备案吗最新国际新闻
  • 两学一做网站专栏怎么设置外贸企业网站推广