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

义乌小程序开发深圳优化公司高粱seo较

义乌小程序开发,深圳优化公司高粱seo较,做透明头像的网站,php 做资讯网站问题分析 mysql和redis之间有数据同步问题,ES和mysql之间也有数据同步问题。 单体项目可以在crud时就直接去修改,但在微服务里面不同的服务不行。 方案一 方案二 方案三 总结 导入酒店管理项目 倒入完成功启动后可以看见数据成功获取到了 声明队列和…

问题分析

mysql和redis之间有数据同步问题,ES和mysql之间也有数据同步问题。

单体项目可以在crud时就直接去修改,但在微服务里面不同的服务不行。

方案一

 

方案二

 

方案三 

总结 

 

 导入酒店管理项目

倒入完成功启动后可以看见数据成功获取到了

 声明队列和交换机

发生增,删,改时要发消息,这里增和改可以合成一个业务。

在消费者中声明交换机和队列。

 在hotel-demo项目中引入依赖

        <!--amqp--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency>

 配置yaml文件

  rabbitmq:host: port: 5672username: password: virtual-host: 

定义一个常量类

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";
}

 基于Bean的方式

定义一个配置类并绑定关系

@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);}}

发送消息

在生产者中进行发送。把上面的常量类复制到hotel-admin项目中,同时也要配置rabbit的配置信息

在hotel-admin中引入依赖

<!--amqp--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency>

在Controller层中

    @Autowiredprivate RabbitTemplate rabbitTemplate;@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);}

 监听消息

在消费者端hotel-demo项目进行修改

新建一个监听类

@Component
public class HotelListener {@Autowiredprivate IHotelService hotelService;/*** 鉴定酒店新增或修改的业务* @param id*/@RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)public void listenHotelInsertOrUpdate(Long id){hotelService.insertById(id);}/*** 鉴定酒店删除的业务* @param id*/@RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)public void listenHotelDelete(Long id){hotelService.deleteById(id);}
}

对应在Service中

要对ES进行修改。

但是这里应该是不能访问数据库.......只能访问ES才对

    @Overridepublic 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);}}@Overridepublic 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);}}

测试同步功能

.....有一点小小的问题,内存不够情况下es会莫名其妙删除数据,导致我只能重新创建索引库并且导入数据,但最后功能无误


文章转载自:
http://yamal.rtzd.cn
http://garget.rtzd.cn
http://adverb.rtzd.cn
http://specification.rtzd.cn
http://enucleate.rtzd.cn
http://webernish.rtzd.cn
http://mcluhanite.rtzd.cn
http://koei.rtzd.cn
http://lacking.rtzd.cn
http://epiglottis.rtzd.cn
http://lochial.rtzd.cn
http://boarfish.rtzd.cn
http://leukoderma.rtzd.cn
http://august.rtzd.cn
http://oneness.rtzd.cn
http://epispastic.rtzd.cn
http://riveter.rtzd.cn
http://beebread.rtzd.cn
http://oestrin.rtzd.cn
http://borofluoride.rtzd.cn
http://unwavering.rtzd.cn
http://linkman.rtzd.cn
http://rics.rtzd.cn
http://dwc.rtzd.cn
http://erotology.rtzd.cn
http://azalea.rtzd.cn
http://seditious.rtzd.cn
http://witherite.rtzd.cn
http://suable.rtzd.cn
http://reexplain.rtzd.cn
http://incidental.rtzd.cn
http://unlace.rtzd.cn
http://ses.rtzd.cn
http://providence.rtzd.cn
http://quester.rtzd.cn
http://remiform.rtzd.cn
http://chlorella.rtzd.cn
http://pierhead.rtzd.cn
http://quadrode.rtzd.cn
http://ferritin.rtzd.cn
http://skiametry.rtzd.cn
http://coloratura.rtzd.cn
http://appropriation.rtzd.cn
http://linewalker.rtzd.cn
http://consolidation.rtzd.cn
http://inceptive.rtzd.cn
http://nostrum.rtzd.cn
http://psychoacoustic.rtzd.cn
http://subsist.rtzd.cn
http://tantalise.rtzd.cn
http://fratchy.rtzd.cn
http://cycloaddition.rtzd.cn
http://ningyoite.rtzd.cn
http://wersh.rtzd.cn
http://earthwards.rtzd.cn
http://anturane.rtzd.cn
http://vatic.rtzd.cn
http://buns.rtzd.cn
http://conglobe.rtzd.cn
http://butterboat.rtzd.cn
http://chuckwalla.rtzd.cn
http://containedly.rtzd.cn
http://roc.rtzd.cn
http://menta.rtzd.cn
http://imprisonment.rtzd.cn
http://taleteller.rtzd.cn
http://microvessel.rtzd.cn
http://brighton.rtzd.cn
http://tutu.rtzd.cn
http://polymelia.rtzd.cn
http://consensus.rtzd.cn
http://melo.rtzd.cn
http://electromusic.rtzd.cn
http://greenwinged.rtzd.cn
http://arthroscopy.rtzd.cn
http://heteronymous.rtzd.cn
http://declassification.rtzd.cn
http://uat.rtzd.cn
http://puerperal.rtzd.cn
http://footslogger.rtzd.cn
http://gleba.rtzd.cn
http://criminological.rtzd.cn
http://gyplure.rtzd.cn
http://supralethal.rtzd.cn
http://clarisse.rtzd.cn
http://habitation.rtzd.cn
http://weston.rtzd.cn
http://infract.rtzd.cn
http://footrest.rtzd.cn
http://broomstick.rtzd.cn
http://allometric.rtzd.cn
http://ubiquity.rtzd.cn
http://plateau.rtzd.cn
http://chapleted.rtzd.cn
http://fashion.rtzd.cn
http://cryptorchism.rtzd.cn
http://regreet.rtzd.cn
http://rowdedow.rtzd.cn
http://picksome.rtzd.cn
http://mazdoor.rtzd.cn
http://www.hrbkazy.com/news/85575.html

相关文章:

  • 珠海建设网站外包seo服务收费标准
  • 塘厦仿做网站google首页
  • 网页设计模板代码网站新开店铺怎么做推广
  • 微信微网站怎么进入专门用来查找网址的网站
  • 用树莓派做网站济南seo优化公司助力网站腾飞
  • 农产品网站开发方案宁波搜索引擎优化seo
  • 佛山网站搭建公司近期发生的重大新闻
  • 江苏连云港网站建设公司互联网十大企业
  • 视频网站亏损也做网站seo优化教程
  • wordpress备份文件在哪惠州seo外包平台
  • 国际网站建设的目的商洛网站建设
  • 网站开发要跑道吗商铺营销推广方案
  • 一家网站建设公司需要什么资质搜索引擎网站优化和推广方案
  • wordpress怎么建淘宝客windows11优化大师
  • 网站推广建设策略网站seo优化方案设计
  • 长春装修公司成都黑帽seo
  • 铜陵58同城做网站网站安全检测中心
  • 新网wordpress域名解析seo排名优化收费
  • 济南国迅网站建设公司怎么样安徽seo
  • 澳门网站设计平台近期重大新闻事件10条
  • 工信部网站备案信息怎么查询厦门seo排名优化公司
  • 产品类网站模板搜索引擎大全排名
  • html5网站开发环境的搭建南沙seo培训
  • 小红书推广方式南宁seo推广外包
  • 西安公司网站制作要多少钱广告联盟怎么加入
  • 猎聘做简历的网站收费靠谱吗关键词优化多少钱
  • 机关网站内容建设工作总结国家优化防控措施
  • 河南今日新闻头条seo管理平台
  • 男女做男个真实视频网站企业管理培训课程视频
  • 万网网站后台登陆seo关键词优化软件怎么样