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

网站推广做的比较好的公司网站开发有什么好的介绍

网站推广做的比较好的公司,网站开发有什么好的介绍,集团网站 wordpress,rails网站开发1.什么是数据同步: 1.Elasticsearch中的酒店数据来自于mysql数据库#xff0c;因此mysql数据发生改变时#xff0c;Elasticsearch也必须跟着改变#xff0c;这个就是Elasticsearch与mysql之间的数据同步 2.数据同步实现方式#xff1a; 常见的数据同步方案有三种#x…1.什么是数据同步: 1.Elasticsearch中的酒店数据来自于mysql数据库因此mysql数据发生改变时Elasticsearch也必须跟着改变这个就是Elasticsearch与mysql之间的数据同步 2.数据同步实现方式 常见的数据同步方案有三种 同步调用异步通知监听binlog 2.1.同步调用 a.解决架构图 1.方案一同步调用 2.基本步骤如下 hotel-demo对外提供接口用来修改elasticsearch中的数据酒店管理服务在完成数据库操作后直接调用hotel-demo提供的接口 b.优缺点分析 优点实现简单粗暴缺点业务耦合度高 2.2.异步通知 a.实现的架构图 1.方案二异步通知 2.流程如下 hotel-admin对mysql数据库数据完成增、删、改后发送MQ消息hotel-demo监听MQ接收到消息后完成Elasticsearch数据修改 b.优缺点分析 优点低耦合实现难度一般缺点依赖mq的可靠性 2.3.监听binlog a.实现的架构图 1.方案三监听binlog 2.流程如下 给mysql开启binlog功能mysql完成增、删、改操作都会记录在binlog中hotel-demo基于canal监听binlog变化实时更新elasticsearch中的内容 b.优缺点分析 优点完全解除服务间耦合缺点开启binlog增加数据库负担、实现复杂度高 3.MQ实现MySQL与Es的数据同步 3.1.案例说明 1.导入hotel-admin项目作为酒店管理的微服务。然后当酒店数据发生增、删、改时要求对Elasticsearch中数据也要完成相同操作 3.2.实现步骤 a.酒店管理项目的运行 1.导入hotel-admin项目并运行启动并测试酒店数据的CRUD运行后访问 http://localhost:8099 2.其中包含了酒店的CRUD功能 b.项目引入ES依赖 1.在hotel-admin、hotel-demo中引入rabbitmq的依赖!--amqp-- dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-amqp/artifactId /dependencyc.MQ架构规划 1.使用RabbitMQ然后MQ结构如下图,声明exchange、queue、RoutingKey 2.声明队列交换机名称在hotel-admin和hotel-demo中的cn.itcast.hotel.constatnts包下新建一个类MqConstantspackage cn.itcast.hotel.constatnts;public class MqConstants {/*** 交换机*/public final static String HOTEL_EXCHANGE hotel.topic;/*** 监听新增和修改的队列*/public final static String HOTEL_INSERT_QUEUE hotel.insert.queue;/*** 监听删除的队列*/public final static String HOTEL_DELETE_QUEUE hotel.delete.queue;/*** 新增或修改的RoutingKey*/public final static String HOTEL_INSERT_KEY hotel.insert;/*** 删除的RoutingKey*/public final static String HOTEL_DELETE_KEY hotel.delete; }3.声明队列交换机在hotel-demo中定义配置类声明队列、交换机package cn.itcast.hotel.config;import cn.itcast.hotel.constants.MqConstants; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.TopicExchange; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;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, true);}Beanpublic Queue deleteQueue(){return new Queue(MqConstants.HOTEL_DELETE_QUEUE, true);}Beanpublic Binding insertQueueBinding(){return BindingBuilder.bind(insertQueue()).to(topicExchange()).with(MqConstants.HOTEL_INSERT_KEY);}Beanpublic Binding deleteQueueBinding(){return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(MqConstants.HOTEL_DELETE_KEY);} }d.生产者发送消息 1.发送MQ消息在hotel-admin中的增、删、改业务中分别发送MQ消息 e.消费端接收消息 1.接收MQ消息hotel-demo接收到MQ消息要做的事情包括 新增消息根据传递的hotel的id查询hotel信息然后新增一条数据到索引库删除消息根据传递的hotel的id删除索引库中的一条数据 1.首先在hotel-demo的cn.itcast.hotel.service包下的IHotelService中新增新增、删除业务void deleteById(Long id);void insertById(Long id);2.给hotel-demo中的cn.itcast.hotel.service.impl包下的HotelService中实现业务 Override public void deleteById(Long id) {try {// 1.准备RequestDeleteRequest request new DeleteRequest(hotel, id.toString());// 2.发送请求client.delete(request, RequestOptions.DEFAULT);} catch (IOException e) {throw new RuntimeException(e);} }Override public void insertById(Long id) {try {// 0.根据id查询酒店数据Hotel hotel getById(id);// 转换为文档类型HotelDoc hotelDoc new HotelDoc(hotel);// 1.准备Request对象IndexRequest request new IndexRequest(hotel).id(hotel.getId().toString());// 2.准备Json文档request.source(JSON.toJSONString(hotelDoc), XContentType.JSON);// 3.发送请求client.index(request, RequestOptions.DEFAULT);} catch (IOException e) {throw new RuntimeException(e);} }3.编写监听器:在hotel-demo中的cn.itcast.hotel.mq包新增一个类package cn.itcast.hotel.mq;import cn.itcast.hotel.constants.MqConstants; import cn.itcast.hotel.service.IHotelService; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;Component public class HotelListener {Autowiredprivate IHotelService hotelService;/*** 监听酒店新增或修改的业务* param id 酒店id*/RabbitListener(queues MqConstants.HOTEL_INSERT_QUEUE)public void listenHotelInsertOrUpdate(Long id){hotelService.insertById(id);}/*** 监听酒店删除的业务* param id 酒店id*/RabbitListener(queues MqConstants.HOTEL_DELETE_QUEUE)public void listenHotelDelete(Long id){hotelService.deleteById(id);} }
http://www.hkea.cn/news/14432305/

相关文章:

  • 校园二手交易网站开发朔州城市建设网站
  • 咸宁网站建设哪家专业赣州酒店网站建设
  • 浏览器正能量不良网站万网主体新增网站备案需要是滴么
  • 广东品牌网站设计欧美网站风格
  • 公司网上注册在哪个网站互联网创业项目拒绝割韭菜
  • 免费做公益网站曲阜企业网站建设
  • 全网最大的精品网站设计网站免费下载
  • 网站的管理页面不知名网站开发
  • 仿模板电影网站网站全屏弹出窗口
  • 哈尔滨模板网站建站网站平台运营方案
  • 网站开发有哪些方式wordpress添加模块
  • 网站排名哪家好建设购物网站多少钱
  • 建设银行ETC的网站是哪个osx 安装 wordpress
  • 国内有做外汇的正规网站吗win2003搭建wordpress
  • 网站空间不够用怎么办网站建设挣钱么
  • 嘉兴网站建设的前景做网站的素材图片
  • 哈尔滨网站建设维护高密做网站哪家好
  • 抚顺营销型网站建设广州 行业 网站建设
  • 怎么让自己的网站稍微变前面点电子名片制作app
  • 云主机怎么上传网站网站关键词优化的步骤
  • 网站开发作业总结深圳市凡客创品科技有限公司
  • iis建设网站教程做网站建本地环境作用
  • 沈阳网站建设21anshan各大网站的404
  • 常州建站价格著名的wordpress主题公园
  • 网站老提示有风险wordpress 忘记用户名密码
  • 找哪些公司做网站wordpress判断手机
  • 微信的官方网站怎么做wordpress html5 音乐
  • 深圳新型材料网站建设做一名优秀网站设计师计划
  • 上海 网站工作室青岛市住房城乡建设厅网站
  • 北京网站建设第一品牌如何做网站推广方法