# simplerpc **Repository Path**: z9066/simplerpc ## Basic Information - **Project Name**: simplerpc - **Description**: it is the simle rpc framework - **Primary Language**: Unknown - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: https://gitee.com/z9066/simplerpc - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2019-07-13 - **Last Updated**: 2024-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 项目名称: simplerpc Description 基于netty开发开源远程服务调用框架 如有问题,欢迎各位留言 Dependency com.qxp simplerpc-starter 0.0.1-SNAPSHOT compile 服务端使用 1.暴露需要被调用的服务 实例: package com.qxp.com.qxp.example.service.impl; import com.qxp.com.qxp.example.service.IService; import Service; @Service public class ServiceImpl implements IService { @Override public String invoke(String message) { return message; } } 2.配置项 spring.simplerpc.port=xxxx spring.simplerpc.ssl=false spring.simplerpc.bossThreadn=16 spring.simplerpc.workThreadn=32 spring.simplerpc.server=true spring.simplerpc.registry.clustername=xx ## 集群的名称 spring.simplerpc.registry.name=xx ## 服务的名称 spring.simplerpc.registry.address=127.0.0.1:8007 ## 服务的地址(本级host+port) spring.simplerpc.registry.type=redis ##注册中心类型 springboot 配置 @SpringBootApplication @EnableSimpleRpcAutoConfig public class SimplerpcExampleServerApplication { public static void main(String[] args) { SpringApplication.run(SimplerpcExampleServerApplication.class, args); } } 客户端使用 方式一: @Component public class TestService { @Autowired private SimpleRpcApplication simpleRpcApplication; public String test(){ try { IService iService = simpleRpcApplication.getBean(IService.class); return iService.invoke("helloworld"); } catch (Exception e) { e.printStackTrace(); } throw new RpcException("error"); } } 方式二: @Component public class TestService { @Autowired private SimpleRpcApplication simpleRpcApplication; public String test(){ try { IService iService = simpleRpcApplication.getBean("serviceImpl",IService.class); return iService.invoke("helloworld"); } catch (Exception e) { e.printStackTrace(); } throw new RpcException("error"); } } 方式三: @Component public class TestService { @Autowired private SimpleRpcApplication simpleRpcApplication; public String test(){ try { IService iService = simpleRpcApplication.getBean(IService.class,"com.qxp.serviceImpl"); return iService.invoke("helloworld"); } catch (Exception e) { e.printStackTrace(); } throw new RpcException("error"); } } 配置项: spring.simplerpc.host=xxx spring.simplerpc.port=xxxx spring.simplerpc.ssl=false spring.simplerpc.clientThreadn=32 spring.simplerpc.client=true spring.simplerpc.registry.type=redis ##注册中心类型 spring.simplerpc.registry.clustername=xx ##注册中心集群名字 springboot 配置 @SpringBootApplication @EnableSimpleRpcAutoConfig public class SimplerpcExampleClientApplication { public static void main(String[] args) { SpringApplication.run(SimplerpcExampleClientApplication.class, args); } } 更新日志: 2019-08-04 监控中心前端改为使用vue实现 添加服務熔段|降级功能 2019-07-31 添加监控中心支持 2019-07-27 添加zookeeper注册中心支持 2019-07-21 添加Redis注册中心