Node.js native Apache Dubbo client on hessian

Clone this repo:
  1. 37ddf42 Merge pull request #188 from binlaniua/master by 胡锋 · 6 months ago master
  2. 828e2b9 fix #187 by Kun Tang · 6 months ago
  3. 1e3e750 Merge pull request #1 from apache/master by Tkk · 6 months ago
  4. 5f79dff Merge pull request #170 from godkun/patch-1 by 胡锋 · 7 months ago
  5. 7790865 fix zone-context readme by 杨昆 · 7 months ago

Apache Dubbo-js

Dubbo-js, using Node.js to embrace the Dubbo ecosystem. See this Demo to find how intelligent this project is.


  • Various transport protocols (Hessian, JSON-RPC etc.) supports
  • Tracing (Runtime information, Call Stack)
  • Multiple registry centers (Zookeeper, Nacos, Redis) supports or connecting to services directly
  • Extensibility, inspired from Koa Middleware
  • Builtin reconnection strategy
  • Typescript type definitions
  • Tools to automatically translate Java interfaces to Typescript type definitions
  • Dubbox supports


Getting Started

yarn add dubbo2.js


Below code snippet shows how to work with the typescript type definitions which automatically translated from Java interfaces.

// ===================== service.ts ==================
// generated by interpret tools
import {BasicTypeProvider} from './providers/com/alibaba/dubbo/demo/BasicTypeProvider';
import {DemoProvider} from './providers/com/alibaba/dubbo/demo/DemoProvider';
import {ErrorProvider} from './providers/com/alibaba/dubbo/demo/ErrorProvider';

export default {

// =============== dubbo.ts ========================
import {Dubbo} from 'dubbo2.js';
import service from './service';

// create dubbo object
const dubbo = new Dubbo<typeof service>({
  application: {name: 'node-dubbo'},
  // zookeeper address
  register: 'localhost:2181',

// main method
(async () => {
  let {res, err} = await dubbo.service.DemoProvider.sayHello('node');
  // print {err: null, res:'hello node from dubbo service'}
  ({res, err} = await dubbo.service.DemoProvider.echo());
  // print {err: null, res: 'pang'}
  ({res, err} = await dubbo.service.DemoProvider.getUserInfo());
  // print {status: 'ok', info: { id: '1', name: 'test' }, err: null}

The automatically translated typescript type definitions are not necessary, below code snippet demonstrates how to use dubbo-js without them.

// create the service to be injected
import {Dubbo} from 'dubbo2.js';

const demoProvider = dubbo =>
    dubboInterface: '',
    version: '1.0.0',
    methods: {
      sayHello(name) {
        return [java.String(name)];

      echo() {},

      test() {},

      getUserInfo() {
        return [
          java.combine('', {
            id: 1,
            name: 'nodejs',
            email: '',

// integrate the service in demoProvider with dubbo object constructor
const service = {

const dubbo = new Dubbo<typeof service>({
  // ....other parameters

For contributors

If you‘d like to contribute, it’s a good start to follow below commands to get a locally runnable project.

# start zookeeper cluster
docker-compose up

# start java
cd java/dubbo-demo
mvn clean install
cd java/dubbo-demo/dubbo-demo-provider
mvn clean package
java -jar target/dubbo-demo-provider-2.6.3-jar-with-dependencies.jar

# build

# start node
cd example/hello-koa
npm run debug:start

# test /hello
curl http://localhost:3000/hello

Next steps


Reporting bugs

Please follow the template for reporting any issues.

Knowledge Sharing

2019-meetup by hufeng


Dubbo-js will not work without:

Many thanks to their authors fengmk2 and dead-horse.


Apache Dubbo is under the Apache 2.0 license. See the LICENSE file for details.