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

网站开发员岗位职责网站开发合同审核要点

网站开发员岗位职责,网站开发合同审核要点,电子商务网站建设与管理实验目的,北京文化传媒有限公司网站建设一、前言 接下来是开展一系列的 SpringCloud 的学习之旅#xff0c;从传统的模块之间调用#xff0c;一步步的升级为 SpringCloud 模块之间的调用#xff0c;此篇文章为第八篇#xff0c;即介绍 Bus 消息总线。 二、概述 2.1 遗留的问题 在上一篇文章的最后#xff0c;我…一、前言 接下来是开展一系列的 SpringCloud 的学习之旅从传统的模块之间调用一步步的升级为 SpringCloud 模块之间的调用此篇文章为第八篇即介绍 Bus 消息总线。 二、概述 2.1 遗留的问题 在上一篇文章的最后我们提出了一个不想手动刷新微服务的问题即想要实现分布式自动刷新配置功能。Spring Cloud Bus 配合 Spring Cloud Config 使用就可以实现配置的动态刷新。 2.2 Bus 是什么 Spring Cloud Bus 是用来将分布式系统的节点与轻量级消息系统链接起来的框架它整合了 Java 的事件处理机制和消息中间件的功能。Spring Clud Bus 目前支持 RabbitMQ 和 Kafka 两种中间件。 2.3 Bus 作用 Spring Cloud Bus 能管理和传播分布式系统间的消息就像一个分布式执行器可用于广播状态更改、事件推送等也可以当作微服务间的通信通道。 2.4 什么是消息总线 在微服务架构的系统中通常会使用轻量级的消息代理来构建一个共用的消息主题并让系统中所有微服务实例都连接上来。由于该主题中产生的消息会被所有实例监听和消费所以称它为消息总线。在总线上的各个实例都可以方便地广播一些需要让其他连接在该主题上的实例都知道的消息。 2.5 基本原理 所有的 ConfigClient 实例都监听 MQ 中同一个 topic默认是 springCloudBus。当一个服务刷新数据的时候它会把这个信息放入到 Topic 中这样其它监听同一 Topic 的服务就能得到通知然后去更新自身的配置。 三、RabbitMQ 环境配置 使用 Spring Cloud Bus 需要安装 rabbitmq安装教程在这里安装完毕后启动登录效果如下图 等到后面的案例搭建完成之后会自动的生成一个交换机如下图 四、Bus 动态刷新全局广播 4.1 设计思想 一共有两种设计思想第一种是利用消息总线触发一个客户端另外一种是利用消息总线触发一个服务端。 4.1.1 触发一个客户端 利用消息总线触发一个客户端 /bus/refresh而刷新所有客户端的配置如下图 4.1.2 触发一个服务端 利用消息总线触发一个服务端 ConfigServer 的 /bus/refresh 端点而刷新所有客户端的配置如下图 4.1.3 设计选型 触发一个服务端的架构4.1.2显然更合适一些因为如果选择架构一就会打破了微服务的职责单一性因为微服务本身是业务模块它本不应该承担配置刷新的职责。并且破坏了微服务各节点的对等性。还存在一定的局限性。例如微服务在迁移时它的网络地址常常会发生变化此时如果想要做到自动刷新那就会增加更多的修改。 4.2 新建工程 为了演示广播效果增加复杂度再以 3355 为模板再制作一个 3366即新创建一个 cloud-config-center-3366 模块pom.xml 内容如下所示 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdcom.springcloud/groupIdartifactIdSpringCloud/artifactIdversion1.0-SNAPSHOT/version/parentartifactIdcloud-config-center-3366/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncoding/propertiesdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-config/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdscoperuntime/scopeoptionaltrue/optional/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependencies /project bootstrap.yml 的内容如下所示 server:port: 3366spring:application:name: config-clientcloud:#Config客户端配置config:label: master #分支名称name: config #配置文件名称profile: dev #读取后缀名称 上述3个综合master分支上config-dev.yml的配置文件被读取http://config-3344.com:3344/master/config-dev.ymluri: http://localhost:3344 #配置中心地址#服务注册到eureka地址 eureka:client:service-url:defaultZone: http://localhost:7001/eureka# 暴露监控端点 management:endpoints:web:exposure:include: * 主启动类的代码如下所示 EnableEurekaClient SpringBootApplication public class ConfigClientMain3366 {public static void main(String[] args){SpringApplication.run(ConfigClientMain3366.class,args);} } 业务类 controller 代码如下所示 package com.springcloud.controller;import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;RestController RefreshScope public class ConfigClientController {Value(${server.port})private String serverPort;Value(${config.info})private String configInfo;GetMapping(/configInfo)public String configInfo(){return serverPort: serverPort\t\n\n configInfo: configInfo;} }4.3 服务端添加消息总线支持 给 cloud-config-center-3344 配置中心模块服务端添加消息总线支持pom.xml 添加如下的依赖 !--添加消息总线RabbitMQ支持-- dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bus-amqp/artifactId /dependency 修改 application.yml 添加 rabbitmq 的相关配置如下 server:port: 3344spring:application:name: cloud-config-center #注册进Eureka服务器的微服务名cloud:config:server:git:uri: https://github.com/BuGeiQianJiuZa/springcloud-config.git #GitHub上面的git仓库名字####搜索目录search-paths:- springcloud-config####读取分支label: master #rabbitmq相关配置 rabbitmq:host: localhostport: 5672username: guestpassword: guest#服务注册到eureka地址 eureka:client:service-url:defaultZone: http://localhost:7001/eureka##rabbitmq相关配置,暴露bus刷新配置的端点 management:endpoints: #暴露bus刷新配置的端点web:exposure:include: bus-refresh 4.4 客户端添加消息总线支持 给 cloud-config-client-3355 客户端添加消息总线支持pom.xml 添加如下的依赖 !--添加消息总线RabbitMQ支持-- dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bus-amqp/artifactId /dependency 修改 bootstrap.yml 添加 rabbitmq 的相关配置如下 server:port: 3355spring:application:name: config-clientcloud:#Config客户端配置config:label: master #分支名称name: config #配置文件名称profile: dev #读取后缀名称 上述3个综合master分支上config-dev.yml的配置文件被读取uri: http://localhost:3344 #配置中心地址k#rabbitmq相关配置 15672是Web管理界面的端口5672是MQ访问的端口rabbitmq:host: localhostport: 5672username: guestpassword: guest#服务注册到eureka地址 eureka:client:service-url:defaultZone: http://localhost:7001/eureka # 暴露监控端点 management:endpoints:web:exposure:include: * # refresh 给 cloud-config-client-3366 客户端添加消息总线支持pom.xml 添加如下的依赖 !--添加消息总线RabbitMQ支持-- dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bus-amqp/artifactId /dependency 修改 bootstrap.yml 添加 rabbitmq 的相关配置如下 server:port: 3366spring:application:name: config-clientcloud:#Config客户端配置config:label: master #分支名称name: config #配置文件名称profile: dev #读取后缀名称 上述3个综合master分支上config-dev.yml的配置文件被读取uri: http://localhost:3344 #配置中心地址k#rabbitmq相关配置 15672是Web管理界面的端口5672是MQ访问的端口rabbitmq:host: localhostport: 5672username: guestpassword: guest#服务注册到eureka地址 eureka:client:service-url:defaultZone: http://localhost:7001/eureka # 暴露监控端点 management:endpoints:web:exposure:include: * # refresh 4.5 测试 分别启动 cloud-eureka-server7001、cloud-config-client-3344、cloud-config-client-3355 和 cloud-config-client-3366然后在 gitHub 上修改版本信息如下图 然后给服务端发送一次 post 请求curl -X POST http://localhost:3344/actuator/bus-refresh 输入 http://config-3344.com:3344/config-dev.yml测试配置中心如下图 输入 http://config-3344.com:3344/config-dev.ymlhttp://localhost:3355/configInfo测试 3355 客户端如下图 ​ 输入 http://localhost:3355/configInfo测试 3366 客户端如下图 ​ 可以看到通过这种方式所有的客户端的配置信息都已经更新了。 五、Bus 动态刷新定点通知 5.1 思想 现在不想全部通知只想定点通知只通知 3355不想通知 3366又该怎么办呢 5.2 解决方案 指定具体某一个实例生效而不是全部是有一个公式的即 http://localhost:配置中心的端口号/actuator/bus-refresh/{destination} /bus/refresh 请求不再发送到具体的服务实例上而是发给 config server 并通过 destination 参数类指定需要更新配置的服务或实例。 5.3 案例 我们这里以刷新运行在 3355 端口上的 config-client 为例更新 gitHub 上的 version 版本如下 ​ 然后执行以下的命令 curl -X POST http://localhost:3344/actuator/bus-refresh/config-client:3355 ​ 输入 http://localhost:3355/configInfo测试 3355 客户端如下图 ​ 输入  http://localhost:3366/configInfo测试 3366 客户端如下图 ​ 可以看到通过这种方式只有 3355 的客户端的配置信息更新了。 5.4 总结 1、ConfigServer 从 gitHub 上面读取配置信息。并在 rabbitmq 上订阅。 2、ConfigClient 从 ConfigServer上面读取配置信息。并在 rabbitmq 上订阅。 3、运维人员手动修改远程 gitHub 上的配置信息。 4、手动给 ConfigServer 发送 post 请求告诉监听器配置信息发生了变化需要刷新。 5、ConfigServer 发送需要刷新的消息给 rabbitmq。 6、ConfigClient 接收到了 rabbitmq 发送的需要刷新的消息。 7、ConfigClient 重新从 ConfigServer上面读取配置信息。
http://www.tj-hxxt.cn/news/141875.html

相关文章:

  • 网站建设注意问题有没有网站做字体变形
  • 做h5商城网站北京百度推广代运营
  • 网站建设费用先付一半推广计划和推广单元有什么区别
  • 爱站权重查询网站推广国外
  • 制作教育类网站wordpress qq注册
  • 济南做网站知识客厅装修风格
  • 网站与平台的开发区别网站帮忙备案
  • 网站开发转包协议长春哪有做网站公司
  • 重庆网站建设c中国空间站名字
  • 网站建设 迅雷下载百度搜一搜
  • 河南整站百度快照优化去哪里找做网站
  • 广州房地产网站建设方案网络营销案例分析怎么写
  • 有什么可以做兼职的正规网站深圳龙岗住房和建设局网站官网
  • 网站建设现在主要做些什么老哥们给个手机能看的2020
  • 网站的开发环境是什么柳州住房城乡建设厅官方网站
  • 2021手机能看的网站wordpress 上传
  • 域名 做网站和邮箱做网站的公司有多少家
  • 天河建设网站系统广州市建设厅网站首页
  • 简单的明星个人网站建设论文福州外贸网站建设
  • 推广一个网站周期网站打开很慢怎么做优化
  • 查排名网站推广费用一般多少
  • 湖南网站建设效果wordpress只有我可以看
  • 新建设电影院+网站江苏省住房城乡建设厅门户网站
  • wordpress怎么上传音频网站移动端优化的重点有哪些
  • 一般云主机可以做视频网站吗河南信合建设投资集团有限公司网站
  • 网站内移动的图片怎么做的上海商城网站
  • 青岛金桥建设机械有限公司网站公司网页设计制作有哪些
  • 网站开发用那个软件鸣蝉小程序制作平台
  • 网站建设金手指排名专业昆明微商城开发
  • 微网站建设比较全面的是淘客怎么做自己的网站