iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
p412726700
V2EX  ›  iDev

nodejs 通过原生 dubbo 协议获取服务

  •  1
     
  •   p412726700 ·
    p412726700 · Mar 4, 2016 · 5836 views
    This topic created in 3859 days ago, the information mentioned may be changed or developed.

    这个项目主要是针对使用 dubbo 服务的团体或者个人

    原生 dubbo 框架可以输出 json 数据供消费者调用,但是假如囿于历史原因 dubbo 不是通过 json 提供数据的,那就只能用原生协议了。之前网上大部分用 node 调取 dubbo 服务都是用 json 格式的库。

    所以,封装了一个通过原生协议调取 dubbo 服务, dubbo 文档中有写到,数据使用 hessian 序列化和反序列化的,只要能通过 nodejs 模拟 hessian 的序列化方式就成功了一大半,在 node 可以直接使用 hessian.js 完成这个工作,剩下的就是实现 dubbo 协议的消息封装。

    node-zookeeper-dubbo

    config

    env

    envirmoment

    conn

    zookeeper conn url

    path

    the service you need

    version

    dubbo version

    Example

    var Service=require('node-zookeeper-dubbo');
    
    var opt={
      env:'test',
      conn:'127.0.0.1:2180',
      path:'com.customer.Service'
    }
    
    var method="getUserByID";
    var arg1={$class:'int',$:123}
    var args=[arg1];
    
    var service = new Service(opt);
    service.excute(method,args,function(err,data){
      if(err){
        console.log(err);
        return;
      }
      console.log(data)
    })
    
    or
    
    service
      .excute(method,args)
      .then(function(data){
        console.log(data);
      })
      .catch(function(err) {
        console.log(err);
      })
    

    you can use js-to-java
    javascript
    var arg1={$class:'int',$:123};
    //equivalent
    var arg1=java('int',123);

    Close zookeeper connection

    Default the zookeeper connection is keep-alive,you can call service.zoo.close() to close the connect;

    1 replies  •  2016-03-06 14:45:37 +08:00
    xi_lin
        1
    xi_lin  
       Mar 6, 2016
    发错节点了吧?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2549 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:59 · PVG 17:59 · LAX 02:59 · JFK 05:59
    ♥ Do have faith in what you're doing.