Skip to content
Node.js native Apache Dubbo client on hessian
TypeScript JavaScript Java Other
Branch: master
Clone or download
ralf0131 Merge pull request #129 from jasonjoo2010/version_wildcard
Make it subscribing all possible targets when set version to '*' or empty
Latest commit 2457af4 Aug 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Aug 17, 2018
.vscode add docker-compose.yaml, add zookeeper cluster May 24, 2019
docs dubbo.subcribe -> .dubbo.subscribe Jul 19, 2019
examples fixed:1. when zk getChildren had occured error, do not set _dubboServ… Jun 22, 2019
java 1. add more java provider get as close to the real scene as possible … Jun 8, 2019
packages Make it subscribing all possible targets when set version to '*' or j… Aug 5, 2019
perf add number-to-num-bytes functions working in deterministic scene Jun 25, 2018
resources update dubbo2 flow Apr 24, 2018
website fixed showcash image Jul 4, 2018
.gitignore release dubbo2.js@2.1.5 Jun 28, 2018
.gitignore-example-from-docusaurus add website Jun 29, 2018
.yarnrc 新的里程碑 Dec 17, 2017
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Apr 30, 2018
CONTRIBUTING.md 新的里程碑 Dec 17, 2017
LICENSE modify Lincence and remove author, ready to community Apr 17, 2018
Makefile refactor loss dubboSetting error tip Nov 21, 2018
README.md fix beginning steps Jun 12, 2019
_config.yml Set theme jekyll-theme-hacker Dec 17, 2017
docker-compose.yml add docker-compose.yaml, add zookeeper cluster May 24, 2019
dubbo.json 添加providerSuffix可配置项,来适配不同的provider后缀名 Jun 28, 2018
lerna.json 新的里程碑 Dec 17, 2017
package.json release zone-context@1.1.0 and add prettier husky auto refmt code whe… Mar 27, 2019
tsconfig.json sync latest code Apr 13, 2018
yarn.lock release zone-context@1.1.0 and add prettier husky auto refmt code whe… Mar 27, 2019

README.md

Apache Dubbo-js

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

Features

  • 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

Architecture

Getting Started

yarn add dubbo2.js

Usage

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 {
  BasicTypeProvider,
  DemoProvider,
  ErrorProvider,
};

// =============== 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',
  service,
});

// 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 =>
  dubbo.proxyService({
    dubboInterface: 'com.alibaba.dubbo.demo.DemoProvider',
    version: '1.0.0',
    methods: {
      sayHello(name) {
        return [java.String(name)];
      },

      echo() {},

      test() {},

      getUserInfo() {
        return [
          java.combine('com.alibaba.dubbo.demo.UserRequest', {
            id: 1,
            name: 'nodejs',
            email: 'node@qianmi.com',
          }),
        ];
      },
    },
  });

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

const dubbo = new Dubbo<typeof service>({
  // ....other parameters
  service,
});

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
make

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

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

Next steps

Guides

Reporting bugs

Please follow the template for reporting any issues.

Knowledge Sharing

2019-meetup by hufeng

Thanks

Dubbo-js will not work without:

Many thanks to their authors fengmk2 and dead-horse.

License

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

You can’t perform that action at this time.