You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/03/25 02:04:17 UTC

[GitHub] [servicecomb-java-chassis] Fang57 opened a new issue #1661: 怎么获取同一APPID Provider的所有实例信息

Fang57 opened a new issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661
 
 
   场景:Consumer向Provider发消息,Provider多实例,想向Provider的所有可用节点发起订阅
   问题:
   1.使用servicecomb的负载均衡,轮询发消息,怎么获取可用节点个数
   2.怎么获取Provider所有的实例信息

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603610249
 
 
   同时像多个服务实例发起订阅,不考虑可靠性,很容易实现。 但是保持可靠性挺难的。
   
   1.  你什么时候发起订阅,发起订阅的频率有设定吗? 因为服务端上下线, 有新的服务实例上下线,你又想过重新触发订阅吗?
   
   2. 发起订阅给所有的服务中心实例,订阅有失败怎么办。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-604944390
 
 
   > 这里提供了一个例子,如何实现你的场景:
   > 
   > #1664
   > 
   > 1. 通过 DiscoveryTree 获取某个微服务的所有实例;
   > 2. 调用 Provider 接口的时候, 指定具体的实例信息。
   > 
   > 不过这个 PR 没合入,有两个问题需要注意:
   > 
   > 1. 如果采用 RestTemplate 调用, 设置 local context 有问题
   > 2. 如果采用 RPC 调用, 需要注意这个接口只能够声明一个 consumer, 携带 InvocationContext 参数
   > 
   > 如果你是在某个 REST 接口里面调用其他服务的接口, 则可以直接使用:
   > 
   > ```
   > ContextUtils.getInvocationContext().addLocalContext 设置地址信息,则不会存在上述两个问题。 
   > ```
   
   
   MicroserviceVersionRule microService = RegistryUtils.getServiceRegistry()
                   .getAppManager()
                   .getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(), "Service", "0.0.0.0+");
   我使用这个方法可以获取到同一APPID下java项目的实例信息,但获取go服务实例信息会报错,请问这个对框架有要求吗
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603610249
 
 
   同时像多个服务实例发起订阅,不考虑可靠性,很容易实现。 但是保持可靠性挺负责的。
   
   1.  你什么时候发起订阅,发起订阅的频率有设定吗? 因为服务端上下线, 有新的服务实例上下线,你又想过重新触发订阅吗?
   
   2. 发起订阅给所有的服务中心实例,订阅有失败怎么办。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603612236
 
 
   在触发特定事件时发起订阅操作,考虑如果使用负载均衡的话,如果失败感知不到具体节点信息。
   当前想的是仅对已上线的实例进行订阅;
   订阅失败记录异常节点信息。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-605838798
 
 
   谢谢分享原因。 [案例: 使用 Context 和 DiscoveryTree 实现轮询调用一个微服务的所有实例](https://docs.servicecomb.io/java-chassis/zh_CN/general-development/context/) 总结了这个场景, 供参考。 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603611821
 
 
   获取可用 Provider的信息, 可以尝试使用方法可以参考 LoadBalancer#chooseServer

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603618140
 
 
   我指的触发事件发起订阅,是业务层面的,这个由Consumer感知

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603612972
 
 
   > 在触发特定事件时发起订阅操作,考虑如果使用负载均衡的话,如果失败感知不到具体节点信息。
   > 当前想的是仅对已上线的实例进行订阅;
   > 订阅失败记录异常节点信息。
   
   触发特定事件感觉不好搞。 你怎么动态感知服务端实例上下线。 在我认知里面, 服务端一个docker 容器重启很常见。 你怎么确定每次server 容器实例重启,你就能感知到。。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603624186
 
 
   SDK 使用 DiscoveryTree 过滤出可用的 服务端实例。 什么条件被认为可用,如何过滤 可参考 [负载均衡](https://docs.servicecomb.io/java-chassis/zh_CN/references-handlers/loadbalance/).
   
   过滤逻辑的初始入口和 过滤结果  可参考:LoadbalanceHandler#getOrCreateLoadBalancer
   
   可以自定义扩展 **DiscoveryFilter** 按照自己的业务拿信息。
   
   过滤之后的实例数据存在 invocation 里面。 可以参考  LoadBalancer#chooseServer 拿
   
   
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-605751296
 
 
   已定位到是go-chassis版本过低导致,换成高版本go-chassis后可通过DiscoveryTree 正常获取实例信息

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603625183
 
 
   > 我指的触发事件发起订阅,是业务层面的,这个由Consumer感知
   
   有没有考虑,因为consumer 触发事件没发起, 但是服务端实例重启,新的 provider 实例 没订阅信息, 造成consumer 接收到的推送消息不全。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603635256
 
 
   这种现象是有可能的,我更倾向于在发起订阅前去查一次provider 的实例列表

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 closed issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 closed issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603611821
 
 
   获取可用 Provider的信息, 可以参考 LoadBalancer#chooseServer

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
Fang57 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-604954176
 
 
   DiscoveryTree discoveryTree = new DiscoveryTree();
   DiscoveryContext context = new DiscoveryContext();
   VersionedCache serversVersionedCache = discoveryTree.discovery(context, RegistryUtils.getAppId(),
                   "Service", "0.0.0.0+");
   List<String> enpoints = serversVersionedCache.data();
   同样有此问题,获取不到go服务的实例信息

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603611821
 
 
   获取可用 Provider的信息, 可以参考 LoadBalancer#chooseServer, invocation 里面有相关服务端数据。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1661: 怎么获取同一APPID Provider的所有实例信息
URL: https://github.com/apache/servicecomb-java-chassis/issues/1661#issuecomment-603738466
 
 
   这里提供了一个例子,如何实现你的场景:
   
   https://github.com/apache/servicecomb-java-chassis/pull/1664 
   
   1. 通过 DiscoveryTree 获取某个微服务的所有实例;
   2. 调用 Provider 接口的时候, 指定具体的实例信息。 
   
   不过这个 PR 没合入,有两个问题需要注意:
   1. 如果采用 RestTemplate 调用, 设置 local context 有问题
   2. 如果采用 RPC 调用, 需要注意这个接口只能够声明一个 consumer, 携带 InvocationContext 参数
   
   如果你是在某个 REST 接口里面调用其他服务的接口, 则可以直接使用:
   
   ```
   ContextUtils.getInvocationContext().addLocalContext 设置地址信息,则不会存在上述两个问题。 
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services