{"id":110552,"date":"2020-05-09T07:12:40","date_gmt":"2020-05-08T23:12:40","guid":{"rendered":"http:\/\/4563.org\/?p=110552"},"modified":"2020-05-09T07:12:40","modified_gmt":"2020-05-08T23:12:40","slug":"%e6%80%8e%e4%b9%88%e5%b0%b1%e6%83%b3%e4%b8%8d%e5%bc%80%e4%ba%86%ef%bc%8c%e8%87%aa%e5%b7%b1%e6%89%8b%e6%92%b8%e4%ba%86-rpc-%e6%a1%86%e6%9e%b6","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=110552","title":{"rendered":"\u600e\u4e48\u5c31\u60f3\u4e0d\u5f00\u4e86\uff0c\u81ea\u5df1\u624b\u64b8\u4e86 RPC \u6846\u67b6"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u600e\u4e48\u5c31\u60f3\u4e0d\u5f00\u4e86\uff0c\u81ea\u5df1\u624b\u64b8\u4e86 RPC \u6846\u67b6               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pwh19920920 <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u9879\u76ee\u771f\u6b63\u542f\u52a8\u662f\u5728 19 \u5e74 5 \u6708\u5427\uff0c\u56e0\u4e3a\u61d2\uff0c\u4e2d\u95f4\u505c\u4e86\u8d77\u7801\u534a\u5e74\uff0c\u6700\u8fd1\u53c8\u5f00\u59cb\u62fe\u4e86\u8d77\u6765\uff0c\u64b8\u8d77\u8896\u5b50\u63a5\u7740\u5e72\uff0c\u7ec8\u4e8e\u5728\u8fd9\u51e0\u5929\u64b8\u51fa\u6765\u4e86\uff0c\u522b\u8bf4\u4e86\uff0c\u6211\u53c8\u8981\u53bb\u517b\u517b\u8eab\u5b50\u4e86\u3002\u3002\u3002\u3002<\/p>\n<h1>\u9879\u76ee\u540d\u5b57 Xmutca-rpc<\/h1>\n<p> <\/p>\n<h3>\u9879\u76ee\u5730\u5740\uff1a https:\/\/github.com\/pwh19920920\/xmutca-rpc<\/h3>\n<p>Xmutca-rpc \u662f\u4e00\u4e2a\u57fa\u4e8e netty \u5f00\u53d1\u7684\u5206\u5e03\u5f0f\u670d\u52a1\u6846\u67b6\uff0c\u63d0\u4f9b\u7a33\u5b9a\u9ad8\u6027\u80fd\u7684 RPC \u8fdc\u7a0b\u670d\u52a1\u8c03\u7528\u529f\u80fd\uff0c\u652f\u6301\u6ce8\u518c\u4e2d\u5fc3\uff0c\u670d\u52a1\u6cbb\u7406\uff0c\u8d1f\u8f7d\u5747\u8861\u7b49\u7279\u6027\uff0c\u5f00\u7bb1\u5373\u7528\u3002<\/p>\n<h2>\u6a21\u5757\u4ecb\u7ecd<\/h2>\n<ul>\n<li>1.xmutca-rpc-core rpc \u6838\u5fc3\u6a21\u5757<\/li>\n<li>2.xmutca-rpc-example rpc \u793a\u4f8b<\/li>\n<li>3.xmutca-rpc-local \u672c\u5730\u5bb9\u5668\u5b9e\u73b0<\/li>\n<li>4.xmutca-rpc-registry-nacos nacos \u6ce8\u518c\u4e2d\u5fc3<\/li>\n<li>5.xmutca-rpc-spring spring \u5bb9\u5668\u5b9e\u73b0<\/li>\n<\/ul>\n<h2>\u5b9e\u73b0\u529f\u80fd<\/h2>\n<ul>\n<li>1.\u6838\u5fc3\u5b9e\u73b0\uff1aSPI \u6269\u5c55\uff0c\u652f\u6301\u52a8\u6001\u52a0\u8f7d\u62d3\u5c55\u5b9e\u73b0\uff0c\u5177\u4f53\u53ef\u4ee5\u770b\u5b9e\u73b0\u7c7b ExtensionLoader<\/li>\n<li>2.\u8d1f\u8f7d\u5747\u8861\uff1a\u73b0\u5728\u5df2\u652f\u6301\u8f6e\u8bad\u8d1f\u8f7d\uff0c\u968f\u673a\u8d1f\u8f7d\uff0c\u4e5f\u53ef\u81ea\u5b9a\u4e49<\/li>\n<li>3.\u96c6\u7fa4\u5bb9\u9519\uff1aFailFast \u5feb\u901f\u5931\u8d25\u3001FailOver \u6545\u969c\u5207\u6362\uff0cFailSafe \u6545\u969c\u5b89\u5168, FailBack \u5931\u8d25\u6062\u590d\uff0cBroadcast \u5e7f\u64ad\u8c03\u7528<\/li>\n<li>4.\u6ce8\u518c\u53d1\u73b0\uff1a\u76ee\u524d\u652f\u6301\u63a5\u5165 nacos<\/li>\n<li>5.\u5bb9\u5668\u652f\u6301\uff1a\u652f\u6301\u672c\u5730 java \u5bb9\u5668\uff0c\u652f\u6301 spring \u5bb9\u5668<\/li>\n<li>6.\u6ce8\u89e3\u62d3\u5c55\uff1a\u652f\u6301\u6ce8\u89e3\u52a0\u8f7d\u63d0\u4f9b\u8005\uff0c\u6ce8\u89e3\u83b7\u53d6\u8fdc\u7a0b rpc \u5bf9\u8c61<\/li>\n<li>7.\u5e8f\u5217\u65b9\u5f0f\uff1a\u652f\u6301 fastJson, Kryo, protostuff \u5e8f\u5217\u5316\uff0c\u9ed8\u8ba4\u8d70 protostuff \u5e8f\u5217\u5316<\/li>\n<li>8.\u6781\u901f\u62d3\u5c55\uff1a\u5141\u8bb8\u52a0\u8f7d\u81ea\u5b9a\u4e49\u7684\u8fc7\u6ee4\u5668\uff0c\u81ea\u5b9a\u4e49\u5bb9\u5668\uff0c\u81ea\u5b9a\u4e49\u6ce8\u518c\u4e2d\u5fc3\u7b49\u7b49\u3002<\/li>\n<\/ul>\n<h2>\u5feb\u901f\u5f00\u59cb<\/h2>\n<pre><code>1. maven \u914d\u7f6e &lt;dependency&gt;     &lt;groupId&gt;com.xmutca&lt;\/groupId&gt;     &lt;artifactId&gt;xmutca-rpc-core&lt;\/artifactId&gt;     &lt;version&gt;0.0.1-SNAPSHOT &lt;\/version&gt; &lt;\/dependency&gt;  &lt;dependency&gt;     &lt;groupId&gt;com.xmutca&lt;\/groupId&gt;     &lt;artifactId&gt;xmutca-rpc-spring&lt;\/artifactId&gt;     &lt;version&gt;0.0.1-SNAPSHOT &lt;\/version&gt; &lt;\/dependency&gt;  &lt;dependency&gt;     &lt;groupId&gt;com.xmutca&lt;\/groupId&gt;     &lt;artifactId&gt;xmutca-rpc-registry-nacos&lt;\/artifactId&gt;     &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;\/dependency&gt;  2. \u5b9a\u4e49\u63a5\u53e3 public interface HelloService {      \/**      * test      * @param msg      * @return      *\/     String sayHello(String msg); }  3. \u63d0\u4f9b\u8005\u5b9e\u73b0\u63a5\u53e3 @Component @Provider(interfaceClass = HelloService.class) public class HelloServiceImpl implements HelloService {      @Autowired     private TestService testService;      @Override     public String sayHello(String msg) {         return testService.test() + \" -&gt; \" + msg;     } }  4. \u63d0\u4f9b\u8005\u914d\u7f6e rpc:   registry: nacos:\/\/localhost:8848 # \u6ce8\u518c\u4e2d\u5fc3\u5730\u5740   provider: # \u63d0\u4f9b\u8005\u914d\u7f6e     corePoolSize: 60       # \u6838\u5fc3\u7ebf\u7a0b\u6570     maxPoolSize: 300       # \u6700\u5927\u7ebf\u7a0b\u6570     port: 8886             # \u63d0\u4f9b\u8005\u7aef\u53e3     scanPackage: com.xmutca.rpc.provider.facade   # \u626b\u63cf\u63d0\u4f9b\u8005\u5305\u8def\u5f84     metadata:              # \u670d\u52a1\u5143\u6570\u636e       group: \"order\"       # \u670d\u52a1\u5206\u7ec4       serviceName: \"test\"  # \u670d\u52a1\u540d\u79f0       version: \"v1.0.0\"    # \u670d\u52a1\u7248\u672c   5. \u542f\u52a8\u63d0\u4f9b\u8005 @EnableXmutcaRpc @SpringBootApplication public class XmutcaSpringProviderApplication {      public static void main(String[] args) {         SpringApplication.run(XmutcaSpringProviderApplication.class, args);     } }  6. \u6d88\u8d39\u8005\u5f15\u7528 @RestController @RequestMapping public class ControllerTest {      @Reference(serviceName = \"test\", group = \"order\", interfaceClass = HelloService.class)     private HelloService helloService;      @RequestMapping(\"\/test\")     public Object test() {         return helloService.sayHello(\"test\");     } }  7. \u6d88\u8d39\u8005\u914d\u7f6e rpc:   registry: nacos:\/\/localhost:8848   consumer:     - timeout: 1000               # \u8d85\u65f6\u914d\u7f6e       metadata:         group: \"order\"            # \u670d\u52a1\u5206\u7ec4         serviceName: \"test\"       # \u670d\u52a1\u540d\u79f0         version: \"v1.0.0\"         # \u670d\u52a1\u7248\u672c  8. \u542f\u52a8\u6d88\u8d39\u8005 @EnableXmutcaRpc @SpringBootApplication public class XmutcaSpringConsumerApplication {      public static void main(String[] args) {         SpringApplication.run(XmutcaSpringConsumerApplication.class, args);     } } <\/code><\/pre>\n<h2>\u4f5c\u8005\u9898\u5916\u8bdd<\/h2>\n<p>\u6b64\u9879\u76ee\u6b22\u8fce\u5404\u4f4d v \u53cb\u8bd5\u7528\uff0c\u4e92\u76f8\u5b66\u4e60\uff0c\u5982\u6709 bug \u53ca\u65f6\u53cd\u9988\uff0c\u8c22\u8c22\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1813040\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzmFina <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c45\u7136\u6ca1\u4eba\u56de\u590d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813041\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Cmxxx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u597d\u5389\u5bb3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813042\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pomelotea2009 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u4e3b\u7684\u6bc5\u529b\u70b9\u8d5e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813043\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : labulaka521 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8d5e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813044\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : OctopusGO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5389\u5bb3\uff0c\u5b66\u4e60\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813045\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ala2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u5199\u4e2a\u6559\u7a0b\uff0c\u83dc\u9e1f\u641e\u4e0d\u5b9a\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1813046\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : pwh19920920 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ala2008 \u5c0f\u54e5\u4f60\u8bf4\u7684\u6559\u7a0b\u662f\u8fd9\u4e2a rpc \u6846\u67b6\u7684\u5b9e\u73b0\u539f\u7406\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u600e\u4e48\u5c31\u60f3\u4e0d\u5f00\u4e86\uff0c\u81ea\u5df1\u624b\u64b8\u4e86 RPC&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/110552"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=110552"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/110552\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=110552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=110552"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=110552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}