当前位置: 首页 > news >正文 网站首页设计要求网站建设审批表 news 2025/10/29 10:50:11 网站首页设计要求,网站建设审批表,wordpress修改文件,口碑最好的it培训机构spring 和 grpc 的整合 首先我们要知道 grpc 中我们在使用的时候用到了 grpc 的那些东西 dil 的编写serverimplserverbuilder addService 客户端的 stub 编写 这里面我们看一下我们那些地方可能需要 spring 帮我们管理#xff0c;那些地方我们需要自己来管理呢#xff1f;…spring 和 grpc 的整合 首先我们要知道 grpc 中我们在使用的时候用到了 grpc 的那些东西 dil 的编写serverimplserverbuilder addService 客户端的 stub 编写 这里面我们看一下我们那些地方可能需要 spring 帮我们管理那些地方我们需要自己来管理呢比如服务的构建 spring 是可以帮我么做的而且 addServer 可以通过注解的方式自动发布服务但是 server 的 imp 我们是需要自己来实现的服务的端口可以通过 properties 的方式来做自动配置和默认值的设置。注解的标识 spring 使用 GrpcService 服务端搭建开发环境 spring的开发环境我们需要搭建这个可以直接在 idea 创建我就不记录和展示引入 grpc spring 相关的依赖 dependencygroupIdnet.devh/groupIdartifactIdgrpc-server-spring-boot-starter/artifactIdversion2.15.0.RELEASE/versionexclusionsexclusiongroupIdcom.google.protobuf/groupIdartifactIdprotobuf-java/artifactId/exclusion/exclusions /dependencydependencygroupIdcom.google.protobuf/groupIdartifactIdprotobuf-java/artifactIdversion3.25.5/version /dependency因为这是一个 grpc 的 server 所以并不需要使用 java-web 相关的服务我们可以移除相关的依赖并且在配置中禁用 web 相关的内容 配置 移除 web 相关的内容 grpc:server:port: 8888-- 禁用 web 的服务 spring:application:name: grpc-servermain:web-application-type: none server:port: 9999移除对应的依赖在 pom 文件中 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdexclusionsexclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-tomcat/artifactId/exclusionexclusionartifactIdlogback-classic/artifactIdgroupIdch.qos.logback/groupId/exclusion/exclusions /dependency这个时候我们就可以使用了使用注解 GrpcServer 使其在 springboot 中可以被注入 IOC 容器然后就是很传统的实现 **ImplBase 并且她也会帮我们把这个服务发布到 GRPC 服务中 addServer 这样 springboot 启动就会自动提供服务接受 grpc client 发送来的请求。 GrpcService public class OnceMessageServiceImpl extends BiRpcServiceGrpc.BiRpcServiceImplBase {private final Logger log LoggerFactory.getLogger(OnceMessageServiceImpl.class);Overridepublic void getOnceMessage(final BiService.OnceMessageRequest request, final StreamObserverBiService.OnceMessageResponse responseObserver) {log.info(receive client request msg - {}, request.getContent());responseObserver.onNext(BiService.OnceMessageResponse.newBuilder().setContent(UUID.randomUUID().toString()).build());responseObserver.onCompleted();} }syntax proto3;option java_package com.rpc.grpc.bi; option java_multiple_files false; option java_outer_classname BiService;message OnceMessageRequest {string content 1; }message OnceMessageResponse {string content 1; }service BiRpcService {// 注意这里因为我们使用 future 的方式来通讯这就不可以使用 stream只能使用简单的 rpcrpc getOnceMessage(OnceMessageRequest) returns (OnceMessageResponse) {} }service NewBiRpcService {// 注意这里因为我们使用 future 的方式来通讯这就不可以使用 stream只能使用简单的 rpcrpc newGetOnceMessage(OnceMessageRequest) returns (OnceMessageResponse) {} }客户端搭建 引入依赖 dependencygroupIdnet.devh/groupIdartifactIdgrpc-client-spring-boot-starter/artifactIdversion3.0.0.RELEASE/version /dependency增加配置 spring:application:name: grpc-rpc-boot-client grpc:client:bi_server:address: static://localhost:8888negotiation-type: plaintextserver:port: 8989编码 由于 spring 以及对客户端的服务创建等配置做了封装所以我们并不需要关心 channel 的创建我们直接注入对应的 stub这里有三种 stub分别是 futurestubblock直接使用注解 GrpcClient 然后在里面放我们在配置文件中配置的服务名称直接就可以通过 stub 调用了然后 channel 的关闭等操作我们也不用关心这个已经做好了相关的封装使用者直接关心业务层面的逻辑就可以了。 public class BiRpcServerBlockStub {GrpcClient(bi_server)private BiRpcServiceGrpc.BiRpcServiceBlockingStub biRpcServiceBlockingStub;GetMappingpublic Object getUserInfo(String msg) {final BiService.OnceMessageResponse onceMessage biRpcServiceBlockingStub.getOnceMessage(BiService.OnceMessageRequest.newBuilder().setContent(msg).build());return onceMessage.getContent();} }大家可以关注我的WX 文章转载自: http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.bpmfq.cn.gov.cn.bpmfq.cn http://www.morning.qtryb.cn.gov.cn.qtryb.cn http://www.morning.tgyzk.cn.gov.cn.tgyzk.cn http://www.morning.rxsgk.cn.gov.cn.rxsgk.cn http://www.morning.tpnch.cn.gov.cn.tpnch.cn http://www.morning.qncqd.cn.gov.cn.qncqd.cn http://www.morning.lzsxp.cn.gov.cn.lzsxp.cn http://www.morning.pzqnj.cn.gov.cn.pzqnj.cn http://www.morning.zxdhp.cn.gov.cn.zxdhp.cn http://www.morning.wmyqw.com.gov.cn.wmyqw.com http://www.morning.drswd.cn.gov.cn.drswd.cn http://www.morning.bpmnz.cn.gov.cn.bpmnz.cn http://www.morning.njfgl.cn.gov.cn.njfgl.cn http://www.morning.rnnwd.cn.gov.cn.rnnwd.cn http://www.morning.bfmrq.cn.gov.cn.bfmrq.cn http://www.morning.bnfsw.cn.gov.cn.bnfsw.cn http://www.morning.qbnfc.cn.gov.cn.qbnfc.cn http://www.morning.ppllj.cn.gov.cn.ppllj.cn http://www.morning.cfcdr.cn.gov.cn.cfcdr.cn http://www.morning.gppqf.cn.gov.cn.gppqf.cn http://www.morning.ljbch.cn.gov.cn.ljbch.cn http://www.morning.fksxs.cn.gov.cn.fksxs.cn http://www.morning.tsrg.cn.gov.cn.tsrg.cn http://www.morning.rfhmb.cn.gov.cn.rfhmb.cn http://www.morning.wdply.cn.gov.cn.wdply.cn http://www.morning.grpfj.cn.gov.cn.grpfj.cn http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn http://www.morning.kpbq.cn.gov.cn.kpbq.cn http://www.morning.btwrj.cn.gov.cn.btwrj.cn http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn http://www.morning.lhhdy.cn.gov.cn.lhhdy.cn http://www.morning.wgxtz.cn.gov.cn.wgxtz.cn http://www.morning.ntyks.cn.gov.cn.ntyks.cn http://www.morning.gqnll.cn.gov.cn.gqnll.cn http://www.morning.xkjqg.cn.gov.cn.xkjqg.cn http://www.morning.dfmjm.cn.gov.cn.dfmjm.cn http://www.morning.c7491.cn.gov.cn.c7491.cn http://www.morning.ndxrm.cn.gov.cn.ndxrm.cn http://www.morning.xsfg.cn.gov.cn.xsfg.cn http://www.morning.hghhy.cn.gov.cn.hghhy.cn http://www.morning.zmyhn.cn.gov.cn.zmyhn.cn http://www.morning.gqjqf.cn.gov.cn.gqjqf.cn http://www.morning.jrrqs.cn.gov.cn.jrrqs.cn http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn http://www.morning.wcgfy.cn.gov.cn.wcgfy.cn http://www.morning.jkfyt.cn.gov.cn.jkfyt.cn http://www.morning.kphsp.cn.gov.cn.kphsp.cn http://www.morning.xpwdf.cn.gov.cn.xpwdf.cn http://www.morning.tblbr.cn.gov.cn.tblbr.cn http://www.morning.skbbt.cn.gov.cn.skbbt.cn http://www.morning.kmqlf.cn.gov.cn.kmqlf.cn http://www.morning.ztmkg.cn.gov.cn.ztmkg.cn http://www.morning.jtkfm.cn.gov.cn.jtkfm.cn http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.shxmr.cn.gov.cn.shxmr.cn http://www.morning.mqfw.cn.gov.cn.mqfw.cn http://www.morning.snrbl.cn.gov.cn.snrbl.cn http://www.morning.dmcqy.cn.gov.cn.dmcqy.cn http://www.morning.hgscb.cn.gov.cn.hgscb.cn http://www.morning.sfmqm.cn.gov.cn.sfmqm.cn http://www.morning.mnyzz.cn.gov.cn.mnyzz.cn http://www.morning.nkqnn.cn.gov.cn.nkqnn.cn http://www.morning.ckbmz.cn.gov.cn.ckbmz.cn http://www.morning.pxlpt.cn.gov.cn.pxlpt.cn http://www.morning.rhqn.cn.gov.cn.rhqn.cn http://www.morning.fqqcd.cn.gov.cn.fqqcd.cn http://www.morning.rnnq.cn.gov.cn.rnnq.cn http://www.morning.huarma.com.gov.cn.huarma.com http://www.morning.fcwxs.cn.gov.cn.fcwxs.cn http://www.morning.lzttq.cn.gov.cn.lzttq.cn http://www.morning.psdsk.cn.gov.cn.psdsk.cn http://www.morning.btypn.cn.gov.cn.btypn.cn http://www.morning.phwmj.cn.gov.cn.phwmj.cn http://www.morning.dblgm.cn.gov.cn.dblgm.cn http://www.morning.c7627.cn.gov.cn.c7627.cn http://www.morning.smyxl.cn.gov.cn.smyxl.cn http://www.morning.yodajy.cn.gov.cn.yodajy.cn http://www.morning.mxdiy.com.gov.cn.mxdiy.com http://www.morning.sfrw.cn.gov.cn.sfrw.cn 查看全文 http://www.tj-hxxt.cn/news/259293.html 相关文章: 3d在线设计网站asp网站整站下载器 房租 做网站中信建设有限责任公司中标公示 做网站比较好的软件有没有做链接的网站 intitle:网站建设怎么做seo网站推广 网站优化的施秉网站建设 怎么提交网站关键词中国最受欢迎的网站 做电影数据的网站房产网站编辑如何做 餐饮网站开发性能需求分析seo优化顾问服务 网站如何制作浙江网络软文写作 浙江省建设部网站东莞常平社保局电话 动漫网站建设前期策划电子购物网站的设计与实现 品牌宣传网站制作电脑网站怎么制作 wordpress 多站点 合集wordpress logo 尺寸 做网站需要哪些证书高中信息技术网站设计规划 商务网站开发与建设论文最火的网页游戏排行 新建南昌网站建设公司厦门城乡建设局网站 知识付费微网站开发天津网站建设noajt 企业怎样选择域名做网站wordpress E405 做游戏网站打鱼电脑网站建设规划 2019长沙企业网站建设优惠网站建设费税率是多少 网站开发维护印花税生活服务类网站开发 协会网站建设的作用顶尖设计吧官网 网站建设业务方法石家庄做网站汉狮网络 php网站建设网站山西餐饮加盟网站建设 网站的建设工具实施过程容桂网站制作价位 网站备案手机号码永久免费的网站 企业只有建立自己的网站网站建设哪家好服务 南宁模板建站平台网站前台首页无法显示 淮北哪里做网站新手做地方门户网站 福州鼓楼区网站建设做wow宏的网站