This is an automated email from the ASF dual-hosted git repository. jerrick pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git
The following commit(s) were added to refs/heads/asf-site by this push: new 3faef3b build site 3faef3b is described below commit 3faef3bb2615632dcf8ddde6772f6d96a2a91328 Author: zhuyong <yong.z...@alibaba-inc.com> AuthorDate: Wed Aug 15 11:47:20 2018 +0800 build site --- build/blog.js | 2 +- en-us/blog/dubbo2-js.html | 233 ++++++++++++++++++++++++++++++++++++++++++++++ en-us/blog/dubbo2-js.json | 4 + en-us/blog/index.html | 2 +- site_config/blog.js | 7 ++ zh-cn/blog/dubbo2-js.html | 6 +- zh-cn/blog/dubbo2-js.json | 2 +- 7 files changed, 250 insertions(+), 6 deletions(-) diff --git a/build/blog.js b/build/blog.js index 331c8f6..e5784cd 100644 --- a/build/blog.js +++ b/build/blog.js @@ -3,4 +3,4 @@ Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ -!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=n.apply(null,r);a&&e.push(a)}else if("object"===o)for(var u in r)i.call(r,u)&&r[u]&&e.push(u)}}return e.join(" ")}var i={}.hasOwnProperty;void 0!==e&&e.exports?(n.default=n,e.exports=n):(r=[],void 0!==(o=function(){return n}.apply(t,r))&&(e.exports=o))}()},function(e,t,n){"use strict";funct [...] \ No newline at end of file +!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=n.apply(null,r);a&&e.push(a)}else if("object"===o)for(var u in r)i.call(r,u)&&r[u]&&e.push(u)}}return e.join(" ")}var i={}.hasOwnProperty;void 0!==e&&e.exports?(n.default=n,e.exports=n):(r=[],void 0!==(o=function(){return n}.apply(t,r))&&(e.exports=o))}()},function(e,t,n){"use strict";funct [...] \ No newline at end of file diff --git a/en-us/blog/dubbo2-js.html b/en-us/blog/dubbo2-js.html new file mode 100644 index 0000000..cabae7d --- /dev/null +++ b/en-us/blog/dubbo2-js.html @@ -0,0 +1,233 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> + <meta name="keywords" content="dubbo2-js" /> + <meta name="description" content="dubbo2-js" /> + <!-- 网页标签标题 --> + <title>dubbo2-js</title> + <link rel="shortcut icon" href="/img/dubbo.ico"/> + <link rel="stylesheet" href="/build/blogDetail.css" /> +</head> +<body> + <div id="root"><div class="blog-detail-page" data-reactroot="" data-reactid="1" data-react-checksum="-969474269"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/en-us/index.html" data-reactid="4"><img class="logo" src="/img/dubbo_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">中</span><div class="header-menu" data-reactid="7"><img class="header-menu-tog [...] +<blockquote> +<p><a href="https://github.com/dubbo/dubbo2.js">dubbo2.js</a> is a Dubbo client for node.js developped by <a href="https://www.qianmi.com/">Qianmiwang</a>. It supports Dubbo's native protocol, which makes the RPC calls between javascript and java efficient and agile. This tool has been contributed to Dubbo's community.</p> +</blockquote> +<h2>Cross-language calls for micro service</h2> +<p>Nowadays, Internet architecture tends to be micro-service way. The discussions about micro-service architecture becomes the most mentioned topic in different technical conferences. In China, most of the companies, such as Qianmiwang, choose Dubbo as their micro-servie architecture solution. As most of the internet companies, Qianmiwang uses various of programming languages. Java is for most of the backend services. Each business based on these backend can choose its own programming la [...] +<ul> +<li>Spring cloud. Spring cloud provides a set of components for micro-service development. It is based on HTTP protocol and is designed in the restful way, which makes it support cross-language calls. Other languages can call the services simply by implementing an HTTP interface.</li> +<li>Service mesh. People call service mesh the next generation of micro-service framework. The core of this solution is SideCar. Even though the concept of SideCar changes a lot during the revolution of Service mesh, its main job never changed: providing reliable communication between different services.</li> +<li>Motan. <a href="https://github.com/weibocom/motan">Motan</a> is an open source cross-language service framework developped by Sina Weibo. Its early version only supports motan-java. However, as the new versions come out, more languages are supported in order to handle the cross-language problem. Its newest version(1.1.0) provides motan-go, motan-php, motan-openresty, etc. Similar to SideCar in Service mesh, Motan forwards messages by mortan-go, which can be considered as an agent. Me [...] +</ul> +<p>According to the solutions below, there are two ways to solve the cross-language calls problem:</p> +<ul> +<li>communicating by a common protocol.</li> +<li>implementing an agent as a protocol adapter.</li> +</ul> +<p>When a new team is choosing technical solutions, what I mentioned below could be our candidates. Meanwhile, the old system's compatibility and migration costs should also be considered. The first trial we did is to work on RPC protocol.</p> +<h2>Cross-language calls by a common protocol</h2> +<h3>SpringMVC</h3> +<p><img src="../../img/blog/springmvc.png" alt="springmvc"></p> +<p>Before achieving the real cross-language calls, the most common solution is to use the http protocol. We can call Dubbo provider indirectly by controller/restController provided by springmvc. This is easy to carry out, but there are lots of inconveniences. firstly, a call will go through too many nodes. Secondly, an extra communication layer (for http protocol) will be involved, but it could have been handled simply by the TCP protocol. Thirdly, we need to implement the RPC interface [...] +<h3>We support some common protocols</h3> +<p>Most of the service management frameworks support multiple protocols, dubbo as well. Besides its own protocol, the common protocols such as Dangdangwang's <a href="https://dangdangdotcom.github.io/dubbox/rest.html">Rest</a> protocol and Qianmiwang's <a href="https://github.com/apache/incubator-dubbo-rpc-jsonrpc">json-rpc</a> protocol are also supported.</p> +<p>The developers getting used to traditional RPC interfaces might feel uncomfortable while working on restful RPC interfaces. On the one hand, this is not good for rebuilding new interfaces. On the other hand, restful style might make these interfaces incompatible with the other protocols used by old interfaces. Of course, if there is no old system problems, using Rest protocol is the easiest implementation of cross-language calls, since most of the languages support it.</p> +<p>Even if Dubbo has tried on restful interface, the difference between rest architecture and RPC architecture should not be ignored. Rest architecture defines each resources, and it needs basic operations of http protocols such as GET, POST, DELETE, PUT. In my opinion, a Rest protocol is more for calls between different systems on the internet, while RPC is suitable for inner system calls. Similar to Rest protocol, json-rpc is also implemented by text sequence and http protocol. Using j [...] +<p>Json-rpc is Qianmiwang's early solution for cross-language protocol. They open-sourced their <a href="https://github.com/dubbo/dubbo-client-py">dubbo-client-py</a> and <a href="https://github.com/QianmiOpen/dubbo-node-client">dubbo-node-client</a>, two clients based on json-rpc protocol. With these tools, we can easily call the rpc services provided by dubbo-provider-java with while using python or node.js. The inner system calls for java services are still mainly implemented by Dubbo [...] +<pre><code class="language-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"dubbo"</span> <span class="hljs-attr">port</span>=<span class="hljs-string">"20880"</span> /></span> +<span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"jsonrpc"</span> <span class="hljs-attr">port</span>=<span class="hljs-string">"8080"</span> /></span> +</code></pre> +<h3>Customized Protocols for Cross-language Support</h3> +<p>The so-called protocol of the microservice framework can be simply interpreted as: message format and serialization scheme. Generally, the service governance framework would provide numbers of protocol configuration items for users to choose from. In addition to the above two common protocols,there exists some other customized protocols like the dubbo protocol, the default protocol for the dubbo framework, and Motan2, a cross-language protocol provided by the motan framework.</p> +<h4>Motan2 for cross-language support</h4> +<p><img src="../../img/blog/motan-protocol-en.png" alt="motan2"></p> +<p>In the original Motan protocol, the protocol message consisted only of the Header and the Body, making deserialization indispensable for acquiring data stored in the Body, like path, param and group, which is terribly unfriendly for cross-language support. Therefore, the content of the protocol was modifiedin Motan2, Weibo released the open-source projects, <a href="https://github.com/weibocom/motan-go/">motan-go</a>, <a href="https://github.com/weibocom/motan-php">motan-php</a> and < [...] +<p><img src="../../img/blog/motan-agent.png" alt="agent"></p> +<p>After observation we find out that there is no big difference between the configuration of Motan2 and the dual protocol. It’s just that the agent here is implicit, and it co-exists with the main service. The most obvious difference is that different languages do not interact directly in agent scheme.</p> +<h4>Dubbo for cross-language support</h4> +<p>Instead of cross-language support, the dubbo protocol was originally designed only for common rpc requests. However, it’s not always the case that we can only choose to support it or not. We can always choose to offer different levels of support. It may be hard to offer cross-language support based on the dubbo protocol, but not impossible. Actually, Qianmiwang succeeded. It conquered the front-end cross-language business field built by nodejs with dubbo2.js. It builds the bridge betw [...] +<h5>Dubbo protocol message format:</h5> +<p><img src="../../img/blog/dubbo-protocol.png" alt="dubbo协议"></p> +<p>Details in dubbo protocol header message:</p> +<ul> +<li>Magic: similar to magic number in Java bytes code files, which is used to determine whether it is a data pack of dubbo protocol. The magic number is the constant, 0xdabb.</li> +<li>Flag: contains 8 bits. The lower four bits are used to indicate the type of serialization tool used for message body data (default hessian). Among the upper four bits, the 1 at first bit indicates request, the 1 at second bit indicates dual transfer, 1 at third bits indicates the heartbeat.</li> +<li>Status: used toset response status. Dubbo defines some types for response. Details can be found in <span data-type="color" style="color:rgb(36, 41, 46)"><span data-type="background" style="background-color:rgba(27, 31, 35, 0.05)">com.alibaba.dubbo.remoting.exchange.Response</span></span></li> +<li>Invoke id: Message id,Type long, Unique indentifier for each request (Due to asynchronous communication, it is used to match the request to the corresponding returned response)</li> +<li>Body length: message body length, type int,record bytes of body content.</li> +<li>Body content: request param, where serializedresponse parameters are stored.</li> +</ul> +<p>Protocol messages will eventually become bytes and be transmitted using TCP. Any language that supports network modules and has a socket will be able to be communicatedwith. Then, why cross-language support is difficult? There are two main obstaclesin calling service in Java using other languages:</p> +<ol> +<li><span data-type="color" style="color:#24292E">How </span><span data-type="color" style="color:#212121">can different languages represent data types in java, especially dynamiclanguages with possible non-strict data types</span>?</li> +<li><span data-type="color" style="color:#24292E">How to serialize string across language?</span></li> +</ol> +<h2>How does dubbo2.js solve problems?</h2> +<p>We have analyzed two obstacles above. The key to dubbo2.js in solving these two problems depends on two class libraries: <a href="https://github.com/node-modules/js-to-java">js-to-java</a>,<a href="https://github.com/node-modules/hessian.js">hessian.js</a>. js-to-java, which makes nodejs have the ability to express Java objects. Hessian.js provides serialization capabilities. With the help of nodejs socket, and a duplicate set of dubbo protocol message format, we can finally achieve [...] +<h2>Quick Start</h2> +<p>To give an intuitive feeling to readers interested in dubbo2.js, this section presents a quick start example that shows how easy it is to call dubbo service using dubbo2.js.</p> +<h3>1. Initiate dubbo-java-provider</h3> +<p>Java provides the backend dubbo service. Firstly, let’s define the service interface:</p> +<pre><code class="language-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">DemoProvider</span> </span>{ + <span class="hljs-function">String <span class="hljs-title">sayHello</span><span class="hljs-params">(String name)</span></span>; + <span class="hljs-function">String <span class="hljs-title">echo</span><span class="hljs-params">()</span> </span>; + <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">test</span><span class="hljs-params">()</span></span>; + <span class="hljs-function">UserResponse <span class="hljs-title">getUserInfo</span><span class="hljs-params">(UserRequest request)</span></span>; +} +</code></pre> +<p>Then we implement the interface:</p> +<pre><code class="language-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DemoProviderImpl</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">DemoProvider</span> </span>{ + <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">sayHello</span><span class="hljs-params">(String name)</span> </span>{ + System.out.println(<span class="hljs-string">"["</span> + <span class="hljs-keyword">new</span> SimpleDateFormat(<span class="hljs-string">"HH:mm:ss"</span>).format(<span class="hljs-keyword">new</span> Date()) + <span class="hljs-string">"] Hello "</span> + name + <span class="hljs-string">", request from consumer: "</span> + RpcContext.getContext().getRemoteAddress()); + <span class="hljs-keyword">return</span> <span class="hljs-string">"Hello "</span> + name + <span class="hljs-string">", response form provider: "</span> + RpcContext.getContext().getLocalAddress(); + } + <span class="hljs-meta">@Override</span> + <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">echo</span><span class="hljs-params">()</span> </span>{ + System.out.println(<span class="hljs-string">"receive...."</span>); + <span class="hljs-keyword">return</span> <span class="hljs-string">"pang"</span>; + } + <span class="hljs-meta">@Override</span> + <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">test</span><span class="hljs-params">()</span> </span>{ + System.out.println(<span class="hljs-string">"test"</span>); + } + <span class="hljs-meta">@Override</span> + <span class="hljs-function"><span class="hljs-keyword">public</span> UserResponse <span class="hljs-title">getUserInfo</span><span class="hljs-params">(UserRequest request)</span> </span>{ + System.out.println(request); + UserResponse response = <span class="hljs-keyword">new</span> UserResponse(); + response.setStatus(<span class="hljs-string">"ok"</span>); + Map<String, String> map = <span class="hljs-keyword">new</span> HashMap<String, String>(); + map.put(<span class="hljs-string">"id"</span>, <span class="hljs-string">"1"</span>); + map.put(<span class="hljs-string">"name"</span>, <span class="hljs-string">"test"</span>); + response.setInfo(map); + <span class="hljs-keyword">return</span> response; + } +} +</code></pre> +<p>After that,<span data-type="color" style="color:#24292E"> we expose the dubbo service with xml files:</span></p> +<pre><code class="language-xml"><span class="php"><span class="hljs-meta"><?</span>xml version=<span class="hljs-string">"1.0"</span> encoding=<span class="hljs-string">"UTF-8"</span><span class="hljs-meta">?></span></span> +<span class="hljs-tag"><<span class="hljs-name">beans</span> <span class="hljs-attr">xmlns:xsi</span>=<span class="hljs-string">"http://www.w3.org/2001/XMLSchema-instance"</span> + <span class="hljs-attr">xmlns:dubbo</span>=<span class="hljs-string">"http://code.alibabatech.com/schema/dubbo"</span> + <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"http://www.springframework.org/schema/beans"</span> + <span class="hljs-attr">xsi:schemaLocation</span>=<span class="hljs-string">"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"</span>></span> + + <span class="hljs-comment"><!-- dubbo provider info, used to compute dependency --></span> + <span class="hljs-tag"><<span class="hljs-name">dubbo:application</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"demo-provider"</span>/></span> + + <span class="hljs-tag"><<span class="hljs-name">dubbo:registry</span> <span class="hljs-attr">protocol</span>=<span class="hljs-string">"zookeeper"</span> <span class="hljs-attr">address</span>=<span class="hljs-string">"localhost:2181"</span>/></span> + + <span class="hljs-comment"><!-- dubbo protocol, used to expose service at port 20880 --></span> + <span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"dubbo"</span> <span class="hljs-attr">port</span>=<span class="hljs-string">"20880"</span>/></span> + + <span class="hljs-comment"><!-- realize a service as a local bean --></span> + <span class="hljs-tag"><<span class="hljs-name">bean</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"demoProvider"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"com.alibaba.dubbo.demo.provider.DemoProviderImpl"</span>/></span> + + <span class="hljs-comment"><!-- claim for service interfaces to expose --></span> + <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.dubbo.demo.DemoProvider"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"demoProvider"</span> <span class="hljs-attr">version</span>=<span class="hljs-string">"1.0.0"</span>/></span> + +<span class="hljs-tag"></<span class="hljs-name">beans</span>></span> +</code></pre> +<p>After we implemented all the configurations on server side, initiate an object initiater to register a dubbo service locally:</p> +<pre><code class="language-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Provider</span> </span>{ + <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> <span class="hljs-keyword">throws</span> Exception </span>{ + ClassPathXmlApplicationContext context = <span class="hljs-keyword">new</span> ClassPathXmlApplicationContext(<span class="hljs-keyword">new</span> String[]{<span class="hljs-string">"META-INF/spring/dubbo-demo-provider.xml"</span>}); + context.start(); + System.in.read(); + } +} +</code></pre> +<h3>2. Implement dubbo client-side for nodejs</h3> +<p>Install dubbo2.js using npm:</p> +<pre><code class="language-sh">npm install dubbo2.js --save +</code></pre> +<p>Configure dubboConfig.ts:</p> +<pre><code class="language-typescript"><span class="hljs-keyword">import</span> { Dubbo, java, TDubboCallResult } <span class="hljs-keyword">from</span> <span class="hljs-string">'dubbo2.js'</span> + +<span class="hljs-keyword">const</span> dubbo = <span class="hljs-keyword">new</span> Dubbo({ + application: {name: <span class="hljs-string">'demo-provider'</span>}, + register: <span class="hljs-string">'localhost:2181'</span>, + dubboVersion: <span class="hljs-string">'2.0.0'</span>, + interfaces: [ + <span class="hljs-string">'com.alibaba.dubbo.demo.DemoProvider'</span>, + ], +}); + +<span class="hljs-keyword">interface</span> IDemoService { + sayHello(name: <span class="hljs-built_in">string</span>): TDubboCallResult<<span class="hljs-built_in">string</span>>; +} + +<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> demoService = dubbo.proxyService<IDemoService>({ + dubboInterface: <span class="hljs-string">'com.alibaba.dubbo.demo.DemoProvider'</span>, + version: <span class="hljs-string">'1.0.0'</span>, + methods: { + sayHello(name: <span class="hljs-built_in">string</span>) { + <span class="hljs-keyword">return</span> [java.String(name)]; + }, + + echo() {}, + + test() {}, + + getUserInfo() { + <span class="hljs-keyword">return</span> [ + java.combine(<span class="hljs-string">'com.alibaba.dubbo.demo.UserRequest'</span>, { + id: <span class="hljs-number">1</span>, + name: <span class="hljs-string">'nodejs'</span>, + email: <span class="hljs-string">'n...@qianmi.com'</span>, + }), + ]; + }, + }, +}); +</code></pre> +<blockquote> +<p>Using typescript brings better coding experience.</p> +</blockquote> +<p>Implement caller class main.ts:</p> +<pre><code class="language-typescript"><span class="hljs-keyword">import</span> {demoService} <span class="hljs-keyword">from</span> <span class="hljs-string">'./dubboConfig'</span> + +demoService.sayHello(<span class="hljs-string">'kirito'</span>).then(<span class="hljs-function">(<span class="hljs-params">{res,err}</span>)=></span>{ + <span class="hljs-built_in">console</span>.log(res) +}); +</code></pre> +<h3>3. Call main.ts:</h3> +<p>Run nodejs client in Debug mode:</p> +<pre><code class="language-sh">DEBUG=dubbo* ts-node main.ts +</code></pre> +<p>Checkout running results:</p> +<pre><code class="language-sh">Hello kirito, response form provider: 172.19.6.151:20880 +</code></pre> +<p>Congratulations!</p> +<h2>Features</h2> +<ul> +<li>Support zookeeper as register center</li> +<li>Support TCP Dubbo Native protocol</li> +<li>Support directly Dubbo connection</li> +<li>Support link tracing</li> +<li>Generate dubbo interface Automatically</li> +</ul> +<h2>More details</h2> +<p>The sample code in this article is available here, <a href="https://github.com/lexburner/Dubbojs-Learning">https://github.com/lexburner/Dubbojs-Learning</a>. +If you don't know much about the dubbo protocol and want to understand how it works, the project provides a sub-moudle: java-socket-consumer, which is implemented in a process-oriented approach, realizing a process of sending dubbo protocal message with native socket and making function calls, and then get response.</p> +</section><footer class="footer-container" data-reactid="19"><div class="footer-body" data-reactid="20"><img src="/img/dubbo_gray.png" data-reactid="21"/><img class="apache" src="/img/apache_logo.png" data-reactid="22"/><div class="cols-container" data-reactid="23"><div class="col col-12" data-reactid="24"><h3 data-reactid="25">Disclaimer</h3><p data-reactid="26">Apache Dubbo is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Incubator. Incubatio [...] + <script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script> + <script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script> + <script> + window.rootPath = ''; + </script> + <script src="/build/blogDetail.js"></script> + <!-- Global site tag (gtag.js) - Google Analytics --> + <script async src="https://www.googletagmanager.com/gtag/js?id=UA-112489517-1"></script> + <script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + + gtag('config', 'UA-112489517-1'); + </script> +</body> +</html> \ No newline at end of file diff --git a/en-us/blog/dubbo2-js.json b/en-us/blog/dubbo2-js.json new file mode 100644 index 0000000..7535d67 --- /dev/null +++ b/en-us/blog/dubbo2-js.json @@ -0,0 +1,4 @@ +{ + "filename": "dubbo2-js.md", + "__html": "<h1>Implementation of cross-language calls by dubbo2.js</h1>\n<blockquote>\n<p><a href=\"https://github.com/dubbo/dubbo2.js\">dubbo2.js</a> is a Dubbo client for node.js developped by <a href=\"https://www.qianmi.com/\">Qianmiwang</a>. It supports Dubbo's native protocol, which makes the RPC calls between javascript and java efficient and agile. This tool has been contributed to Dubbo's community.</p>\n</blockquote>\n<h2>Cross-language calls for micro service</h2>\n<p>Nowada [...] +} \ No newline at end of file diff --git a/en-us/blog/index.html b/en-us/blog/index.html index 84b4607..e111bc8 100644 --- a/en-us/blog/index.html +++ b/en-us/blog/index.html @@ -12,7 +12,7 @@ <link rel="stylesheet" href="/build/blog.css" /> </head> <body> - <div id="root"><div class="blog-list-page" data-reactroot="" data-reactid="1" data-react-checksum="-1676105064"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/en-us/index.html" data-reactid="4"><img class="logo" src="/img/dubbo_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">中</span><div class="header-menu" data-reactid="7"><img class="header-menu-togg [...] + <div id="root"><div class="blog-list-page" data-reactroot="" data-reactid="1" data-react-checksum="2036590217"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/en-us/index.html" data-reactid="4"><img class="logo" src="/img/dubbo_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">中</span><div class="header-menu" data-reactid="7"><img class="header-menu-toggl [...] <script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script> <script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script> <script> diff --git a/site_config/blog.js b/site_config/blog.js index b674115..2f81aa9 100644 --- a/site_config/blog.js +++ b/site_config/blog.js @@ -4,6 +4,13 @@ export default { postsTitle: 'All posts', list: [ { + title: 'Implementation of cross-language calls by dubbo2.js', + author: '@Stella0824', + dateStr: 'August 14th, 2018', + desc: 'This blog describes how to use dubbo2.js for cross-language calls', + link: '/en-us/blog/dubbo2-js.html', + }, + { title: 'The basic usage of Dubbo Provider configuration', author: '@Ziyang-Wu', dateStr: 'August 14th, 2018', diff --git a/zh-cn/blog/dubbo2-js.html b/zh-cn/blog/dubbo2-js.html index 5027d26..04bd0d2 100644 --- a/zh-cn/blog/dubbo2-js.html +++ b/zh-cn/blog/dubbo2-js.html @@ -12,7 +12,7 @@ <link rel="stylesheet" href="/build/blogDetail.css" /> </head> <body> - <div id="root"><div class="blog-detail-page" data-reactroot="" data-reactid="1" data-react-checksum="1418001176"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/zh-cn/index.html" data-reactid="4"><img class="logo" src="/img/dubbo_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">En</span><div class="header-menu" data-reactid="7"><img class="header-menu-to [...] + <div id="root"><div class="blog-detail-page" data-reactroot="" data-reactid="1" data-react-checksum="1654253263"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/zh-cn/index.html" data-reactid="4"><img class="logo" src="/img/dubbo_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">En</span><div class="header-menu" data-reactid="7"><img class="header-menu-to [...] <blockquote> <p><a href="https://github.com/dubbo/dubbo2.js">dubbo2.js</a> 是 <a href="https://www.qianmi.com/">千米网</a> 贡献给 dubbo 社区的一款 nodejs dubbo 客户端,它提供了 nodejs 对原生 dubbo 协议的支持,使得 nodejs 和 java 这两种异构语言的 rpc 调用变得便捷,高效。</p> </blockquote> @@ -78,7 +78,7 @@ <li>序列化方案如何做到跨语言</li> </ol> <h2>dubbo2.js解决方案</h2> -<p>上面我们分析出了两个难点,dubbo2.js 解决这两个问题的关键依赖于两个类库:<a href="https://github.com/node-modules/js-to-java">js-to-java</a>,<a href="https://github.com/node-modules/hessian.js">hessian.js</a> 。js-to-java 使得 nodejs 具备 java 对象的表达能力,而 hessian.js 提供了序列化能力。借助于 nodejs 的 socket ,妇科一套 dubbo 协议的报文格式,最终便实现了 nodejs 对 java-dubbo-provider 的调用。</p> +<p>上面我们分析出了两个难点,dubbo2.js 解决这两个问题的关键依赖于两个类库:<a href="https://github.com/node-modules/js-to-java">js-to-java</a>,<a href="https://github.com/node-modules/hessian.js">hessian.js</a> 。js-to-java 使得 nodejs 具备 java 对象的表达能力,而 hessian.js 提供了序列化能力。借助于 nodejs 的 socket ,复制一套 dubbo 协议的报文格式,最终便实现了 nodejs 对 java-dubbo-provider 的调用。</p> <h2>dubbo2.js快速入门</h2> <p>为了让对 dubbo2.js 感兴趣的读者有一个直观的体验,本节呈现一个快速入门示例,让你体会到使用 dubbo2.js 调用 dubbo 服务是一件多么轻松的事。</p> <h3>1. 创建 dubbo-java-provider</h3> @@ -222,7 +222,7 @@ demoService.sayHello(<span class="hljs-string">'kirito'</span>).then(<span class <li>dubbo 接口自动生成</li> </ul> <h2>更多细节</h2> -<p>本文中的示例代码,提供在此处,<a href="https://github.com/lexburner/Dubbojs-Learning">https://github.com/lexburner/Dubbojs-Learning</a> 。如果你对 dubbo 协议不慎了解,想要理解它的工作原理,项目中提供了一个子 moudle — java-socket-consumer,使用面向过程的思路实现了 java-socket-consumer,完成了原生 socket 发送 dubbo 协议报文,完成方法调用,并获取响应的全流程。</p> +<p>本文中的示例代码,提供在此处,<a href="https://github.com/lexburner/Dubbojs-Learning">https://github.com/lexburner/Dubbojs-Learning</a> 。如果你对 dubbo 协议不甚了解,想要理解它的工作原理,项目中提供了一个子 moudle — java-socket-consumer,使用面向过程的思路实现了 java-socket-consumer,完成了原生 socket 发送 dubbo 协议报文,完成方法调用,并获取响应的全流程。</p> </section><footer class="footer-container" data-reactid="19"><div class="footer-body" data-reactid="20"><img src="/img/dubbo_gray.png" data-reactid="21"/><img class="apache" src="/img/apache_logo.png" data-reactid="22"/><div class="cols-container" data-reactid="23"><div class="col col-12" data-reactid="24"><h3 data-reactid="25">Disclaimer</h3><p data-reactid="26">Apache Dubbo is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Incubator. Incubatio [...] <script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script> <script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script> diff --git a/zh-cn/blog/dubbo2-js.json b/zh-cn/blog/dubbo2-js.json index f9cd571..bb44a71 100644 --- a/zh-cn/blog/dubbo2-js.json +++ b/zh-cn/blog/dubbo2-js.json @@ -1,4 +1,4 @@ { "filename": "dubbo2-js.md", - "__html": "<h1>从跨语言调用到dubbo2.js</h1>\n<blockquote>\n<p><a href=\"https://github.com/dubbo/dubbo2.js\">dubbo2.js</a> 是 <a href=\"https://www.qianmi.com/\">千米网</a> 贡献给 dubbo 社区的一款 nodejs dubbo 客户端,它提供了 nodejs 对原生 dubbo 协议的支持,使得 nodejs 和 java 这两种异构语言的 rpc 调用变得便捷,高效。</p>\n</blockquote>\n<h2>微服务跨语言调用</h2>\n<p>微服务架构已成为目前互联网架构的趋势,关于微服务的讨论,几乎占据了各种技术大会的绝大多数版面。国内使用最多的服务治理框架非阿里开源的 dubbo 莫属,千米网也选择了 dubbo 作为微服务治理框架。另一方面,和大多数互联网公司一样,千米的开发语言是多样的,大多数后端业务由 java 支撑,而每个业务线有各自开发语言的选择权,便出现了 nodejs,python,g [...] + "__html": "<h1>从跨语言调用到dubbo2.js</h1>\n<blockquote>\n<p><a href=\"https://github.com/dubbo/dubbo2.js\">dubbo2.js</a> 是 <a href=\"https://www.qianmi.com/\">千米网</a> 贡献给 dubbo 社区的一款 nodejs dubbo 客户端,它提供了 nodejs 对原生 dubbo 协议的支持,使得 nodejs 和 java 这两种异构语言的 rpc 调用变得便捷,高效。</p>\n</blockquote>\n<h2>微服务跨语言调用</h2>\n<p>微服务架构已成为目前互联网架构的趋势,关于微服务的讨论,几乎占据了各种技术大会的绝大多数版面。国内使用最多的服务治理框架非阿里开源的 dubbo 莫属,千米网也选择了 dubbo 作为微服务治理框架。另一方面,和大多数互联网公司一样,千米的开发语言是多样的,大多数后端业务由 java 支撑,而每个业务线有各自开发语言的选择权,便出现了 nodejs,python,g [...] } \ No newline at end of file