{"id":14801,"date":"2023-12-04T16:31:36","date_gmt":"2023-12-04T08:31:36","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=14801"},"modified":"2023-12-14T10:46:07","modified_gmt":"2023-12-14T02:46:07","slug":"dubbo-he-xin-de-pei-zhi-you-na-xie","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/04\/dubbo-he-xin-de-pei-zhi-you-na-xie\/","title":{"rendered":"Dubbo\u6838\u5fc3\u7684\u914d\u7f6e\u6709\u54ea\u4e9b\uff1f"},"content":{"rendered":"<p>Dubbo \u7684\u6838\u5fc3\u914d\u7f6e\u4e3b\u8981\u5305\u62ec\u670d\u52a1\u63d0\u4f9b\u8005\uff08Provider\uff09\u548c\u670d\u52a1\u6d88\u8d39\u8005\uff08Consumer\uff09\u4e24\u65b9\u9762\u7684\u914d\u7f6e\u3002\u4ee5\u4e0b\u662f Dubbo \u6838\u5fc3\u7684\u4e00\u4e9b\u914d\u7f6e\u9879\uff1a<\/p>\n<h3><a id=\"%E6%9C%8D%E5%8A%A1%E6%8F%90%E4%BE%9B%E8%80%85%E9%85%8D%E7%BD%AE%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u670d\u52a1\u63d0\u4f9b\u8005\u914d\u7f6e\uff1a<\/h3>\n<ol>\n<li>\n<strong>\u670d\u52a1\u63a5\u53e3\u5b9a\u4e49\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 <code>@DubboService<\/code> \u6ce8\u89e3\u6216\u5728 XML \u914d\u7f6e\u4e2d\u58f0\u660e\u670d\u52a1\u7684\u63a5\u53e3\u7c7b\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-java\">@DubboService(interfaceClass = xxxService.class)\n<\/code><\/pre>\n<pre><code class=\"language-xml\">&lt;dubbo:service interface=&quot;com.xxx.xxxService&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u63d0\u4f9b\u8005\u5e94\u7528\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u63d0\u4f9b\u8005\u7684\u5e94\u7528\u4fe1\u606f\uff0c\u5305\u62ec\u5e94\u7528\u540d\u79f0\u7b49\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:application name=&quot;provider-app&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u63d0\u4f9b\u8005\u6ce8\u518c\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u63d0\u4f9b\u8005\u7684\u6ce8\u518c\u4e2d\u5fc3\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:registry address=&quot;zookeeper:\/\/127.0.0.1:2181&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u63d0\u4f9b\u8005\u534f\u8bae\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u63d0\u4f9b\u8005\u4f7f\u7528\u7684\u534f\u8bae\u3001\u7aef\u53e3\u7b49\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:protocol name=&quot;dubbo&quot; port=&quot;20880&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u63d0\u4f9b\u8005\u63d0\u4f9b\u7684\u670d\u52a1\u5b9e\u73b0\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b9e\u73b0\u670d\u52a1\u63a5\u53e3\u63d0\u4f9b\u5177\u4f53\u7684\u670d\u52a1\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-java\">public class XxxServiceImpl implements XxxService {\n    \/\/ \u5b9e\u73b0\u63a5\u53e3\u65b9\u6cd5\n}\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3><a id=\"%E6%9C%8D%E5%8A%A1%E6%B6%88%E8%B4%B9%E8%80%85%E9%85%8D%E7%BD%AE%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u670d\u52a1\u6d88\u8d39\u8005\u914d\u7f6e\uff1a<\/h3>\n<ol>\n<li>\n<strong>\u670d\u52a1\u5f15\u7528\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 <code>@DubboReference<\/code> \u6ce8\u89e3\u6216\u5728 XML \u914d\u7f6e\u4e2d\u58f0\u660e\u5bf9\u670d\u52a1\u7684\u5f15\u7528\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-java\">@DubboReference(interfaceClass = XxxService.class)\n<\/code><\/pre>\n<pre><code class=\"language-xml\">&lt;dubbo:reference interface=&quot;com.xxx.xxxService&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u6d88\u8d39\u8005\u5e94\u7528\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u6d88\u8d39\u8005\u7684\u5e94\u7528\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:application name=&quot;consumer-app&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u6d88\u8d39\u8005\u6ce8\u518c\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u6d88\u8d39\u8005\u7684\u6ce8\u518c\u4e2d\u5fc3\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:registry address=&quot;zookeeper:\/\/127.0.0.1:2181&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u6d88\u8d39\u8005\u8c03\u7528\u8d85\u65f6\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u8c03\u7528\u7684\u8d85\u65f6\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:reference timeout=&quot;3000&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u6d88\u8d39\u8005\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u6d88\u8d39\u8005\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:reference loadbalance=&quot;roundrobin&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u6d88\u8d39\u8005\u96c6\u7fa4\u5bb9\u9519\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u6d88\u8d39\u8005\u7684\u96c6\u7fa4\u5bb9\u9519\u7b56\u7565\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:reference cluster=&quot;failover&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u670d\u52a1\u8c03\u7528\u91cd\u8bd5\u6b21\u6570\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u914d\u7f6e\u670d\u52a1\u8c03\u7528\u5931\u8d25\u65f6\u7684\u91cd\u8bd5\u6b21\u6570\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">&lt;dubbo:reference retries=&quot;2&quot; \/&gt;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u8fd9\u4e9b\u914d\u7f6e\u662f Dubbo \u4e2d\u6bd4\u8f83\u57fa\u7840\u4e14\u5e38\u7528\u7684\u4e00\u4e9b\u914d\u7f6e\u9879\u3002\u6839\u636e\u5177\u4f53\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u53ef\u80fd\u9700\u8981\u8fdb\u4e00\u6b65\u914d\u7f6e\u4f8b\u5982\u8d1f\u8f7d\u5747\u8861\u3001\u96c6\u7fa4\u5bb9\u9519\u3001\u7248\u672c\u7ba1\u7406\u7b49\u65b9\u9762\u7684\u9ad8\u7ea7\u914d\u7f6e\u3002\u5728\u4f7f\u7528 Dubbo \u65f6\uff0c\u5efa\u8bae\u8be6\u7ec6\u9605\u8bfb\u5b98\u65b9\u6587\u6863\uff0c\u4ee5\u4e86\u89e3\u66f4\u591a\u53ef\u7528\u7684\u914d\u7f6e\u9879\u548c\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dubbo \u7684\u6838\u5fc3\u914d\u7f6e\u4e3b\u8981\u5305\u62ec\u670d\u52a1\u63d0\u4f9b\u8005\uff08Provider\uff09\u548c\u670d\u52a1\u6d88\u8d39\u8005\uff08Consumer\uff09\u4e24\u65b9\u9762\u7684\u914d\u7f6e\u3002\u4ee5\u4e0b [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[],"class_list":["post-14801","post","type-post","status-publish","format-standard","hentry","category-dubbo"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=14801"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14801\/revisions"}],"predecessor-version":[{"id":48092,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14801\/revisions\/48092"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=14801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=14801"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=14801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}