omnip620 / node-zookeeper-dubbo

A middleware helps node to communicate dubbo by using its default protocol, which is registered in zookeeper
300 stars 80 forks source link

关于dubbo的version参数的设置遇到问题 #55

Closed BrickCarvingArtist closed 6 years ago

BrickCarvingArtist commented 6 years ago

index.js第104行if (zoo.version === self._version && zoo.group === self._group) {

当dubbo协议的服务的zoo里没有传入version参数时,就是那个dubbo://的url里的version参数,这个判断就通不过。
在我们这里java那边把版本信息传作了dubbo参数,即非version=2.4.9而是dubbo=2.4.9
然后我把它改作if (zoo.dubbo === self._version && zoo.group === self._group) {通过了这个判断,但是远程调用时报错

com.alibaba.dubbo.remoting.RemotingException: Not found exported service: com.**.**.api.**Service:2.4.9:20875 in [com.**.**.api.**Service:20875, com.**.**.api.**Service:20875, com.**.**.api.**Service:20875], may be version or group mismatch , channel: consumer: /172.19.5.159:59617 --> provider: /172.19.5.14:20875, message:RpcInvocation [methodName=**method, parameterTypes=[long], arguments=[11446], attachments={dubbo=2.4.9, input=187, path=com.**.**.api.**Service, interface=com.**.**.api.**Service, timeout=6000, version=2.4.9}]
com.alibaba.dubbo.remoting.RemotingException: Not found exported service: com.**.**.api.**Service:2.4.9:20875 in [com.**.**.api.**Service:20875, com.**.**.api.**Service:20875, com.**.**.api.**Service:20875], may be version or group mismatch , channel: consumer: /172.19.5.159:59617 --> provider: /172.19.5.14:20875, message:RpcInvocation [methodName=**method, parameterTypes=[long], arguments=[11446], attachments={dubbo=2.4.9, input=187, path=com.**.**.api.**Service, interface=com.**.**.api.**Service, timeout=6000, version=2.4.9}]
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.getInvoker(DubboProtocol.java:217)
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:86)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
        at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
        at com.alibaba.dubbo.remoting.transport.dispather.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

最后我的解决方案:

  1. 在index.js的第65行插入this._revision = depend.revision;
  2. 将104行的条件判断改为if (zoo.revision === self._revision && zoo.group === self._group) {
  3. 入口参数配置
    dependencies: {
    **Service: {
    interface: "com.**.**.api.**Service",
    // version: "2.4.9",
    revision: "2.0-SNAPSHOT",
    methodSignature: {
      **method(id){
        return [java.long(id)];
      }
    }
    }
    }

    远程调用com.**.**.api.**Service中的**method成功。

大神,要不在入口调整下参数配置方式之类的,能让其他遇到我这种情况下不改源码的方式来处理这种问题?我不懂java,所以为什么我这么改了java那边就能调通了,也不知道原因,就只好先将就了,不过肯定不是长久之计。希望可以帮助一下我,感激不尽。 @p412726700

omnip620 commented 6 years ago

呃... 其实这个版本不是dubbo版本 readme手误写错了 你可以看下例子 这个参数是用来代表服务版本的 你直接 version: "2.0-SNAPSHOT" 试试 应该可以的

omnip620 commented 6 years ago

@BrickCarvingArtist

BrickCarvingArtist commented 6 years ago

好的,我周一上班的时候试试再给你反馈,现在家里没网络环境😂

BrickCarvingArtist commented 6 years ago

改完后报

can't find  the zoo: com.**.**.**.api.service.**Service group: undefined,pls check dubbo service!

我们公司的dubbo没有设置group,不同服务会有2.4.9和2.5.3两个dubbo版本的差异

omnip620 commented 6 years ago

group如果没有的话 不用写group字段