公司搞前后端分离后端原来是用java写的服务通信是用node dubbo,现在想用node做前后端分离, 网上找了很多node dubbo 的 var zookeeper = require(‘node-zookeeper-client’);
var client = zookeeper.createClient(‘192.168.16.244:2181’); var path = ‘/com.szy.hms.openservice.facade.IMySchoolFacade’;
function getData(client, path) { client.getData( path, function (event) { console.log(‘Got event: %s’, event); getData(client, path); }, function (error, data, stat) { if (error) { console.log(‘Error occurred when getting data: %s.’, error); return; }
console.log(
'Node: %s has data: %s, version: %d',
path,
data ? data.toString() : undefined,
stat.version
);
}
); }
client.once(‘connected’, function () { console.log(‘Connected to ZooKeeper.’); getData(client, path); });
client.connect();
最后都是 Connected to ZooKeeper. Node: /com.szy.hms.openservice.facade.IMySchoolFacade has data: undefined, version: 0