You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "BellaJiangxia (GitHub)" <gi...@apache.org> on 2018/10/31 09:11:17 UTC

[GitHub] [incubator-dubbo] BellaJiangxia opened issue #2720: 路由规则无法生效的问题

在管理页面设置了该路由规则,没起作用,
我看网上说“使用URL描述一条路由规则,并将存储在注册中心${service}/routers目录下,然后通知相关订阅者(服务消费者【调用方】)。“,这句话什么意思,是还要在zookeeper里面配置什么吗


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
![pb1spi_ y4 yux3qu 4jn1h](https://user-images.githubusercontent.com/31379334/47778136-2513f100-dd31-11e8-9459-026f04f60541.png)


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] beiwei30 commented on issue #2720: 路由规则无法生效的问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
是不是把优先级理解反了?越小优先级越高。

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
我理解了,就是过滤条件就是调用满足该过滤条件的服务吧,但是现在有个问题,两个路由规则,一个过滤条件为调用20880端口服务,优先级0,一个调用20883端口服务,优先级4,为啥反而执行优先级为0的路由规则呢



[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] zonghaishang commented on issue #2720: 路由规则无法生效的问题

Posted by "zonghaishang (GitHub)" <gi...@apache.org>.
```java
    @Override
    public int compareTo(Router o) {
        if (o == null || o.getClass() != ConditionRouter.class) {
            return 1;
        }
        ConditionRouter c = (ConditionRouter) o;
        return this.priority == c.priority ? url.toFullString().compareTo(c.url.toFullString()) : (this.priority > c.priority ? 1 : -1);
    }
```

优先级越小优先执行

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
![gmrn hv s_ 5txy5bkwa 6](https://user-images.githubusercontent.com/31379334/47778496-ff3b1c00-dd31-11e8-8950-18058400f02a.png)
![p 4jl88 2r t2 72enc6m3](https://user-images.githubusercontent.com/31379334/47778513-04986680-dd32-11e8-95df-4f208aba6e60.png)
消费者打印出来的数据依然是20883端口的

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
但是我在dubbo-admin控制了没起作用啊
![l x0qikq61uc igxd i560](https://user-images.githubusercontent.com/31379334/47778105-11688a80-dd31-11e8-8175-58c973105996.png)


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] beiwei30 commented on issue #2720: 路由规则无法生效的问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
是不是把优先级理解反了?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] beiwei30 commented on issue #2720: 路由规则无法生效的问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
意思是说,你在控制台上配置了路由规则之后,对应的路由规则会存储在 zookeeper 的 `/dubbo/${service}/routers` 下。

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] zonghaishang closed issue #2720: 路由规则无法生效的问题

Posted by "zonghaishang (GitHub)" <gi...@apache.org>.
[ issue closed by zonghaishang ]

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
然后就可以直接消费者了吧?还是需要做什么事?我设置了两个
![pb1spi_ y4 yux3qu 4jn1h](https://user-images.githubusercontent.com/31379334/47778287-81771080-dd31-11e8-856d-0b32579c5f5c.png)
![gy vu dvu oy w8 womvv](https://user-images.githubusercontent.com/31379334/47778289-820fa700-dd31-11e8-83fe-534b42aa968c.png),就是说不能访问20883端口和20881端口,还剩一个20880的提供者,但是调用的服务并不是20880上的



[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
我测试了一下,感觉是优先级越低的越靠前执行呢

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] BellaJiangxia commented on issue #2720: 路由规则无法生效的问题

Posted by "BellaJiangxia (GitHub)" <gi...@apache.org>.
事实上是优先级越低的越先执行吗

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] zonghaishang commented on issue #2720: 路由规则无法生效的问题

Posted by "zonghaishang (GitHub)" <gi...@apache.org>.
```java
    @Override
    public int compareTo(Router o) {
        if (o == null || o.getClass() != ConditionRouter.class) {
            return 1;
        }
        ConditionRouter c = (ConditionRouter) o;
        return this.priority == c.priority ? url.toFullString().compareTo(c.url.toFullString()) : (this.priority > c.priority ? 1 : -1);
    }
```

优先级越小优先执行,比如router1 优先级0, router2 优先级1, router1和router2配置一样,先执行router1的结果,然后把结果交给router2继续执行

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2720 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org