You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by Ian Luo <ia...@gmail.com> on 2018/08/10 07:52:55 UTC

Re: Can we get the address URL of consumers?

You should try org.apache.dubbo.config.ReferenceConfig#toUrls.

On Fri, Aug 10, 2018 at 11:29 AM 余传秋 <16...@qq.com> wrote:

> I just started learning Dubbo recently. Yestday,I uesd the
> ServiceConfig.getExportedUrls() and got the addree URL of provider,and I
> want get the address URL of consumer by dubbo api, can you help me,thanks!
>
>
> the code I use:
> Provider:ServiceConfig<IQueryUserInfoService> service = new
> ServiceConfig<IQueryUserInfoService>(); //
> 此实例很重,封装了与注册中心的连接,请自行缓存,否则可能造成内存和连接泄漏
> service.setApplication(application);
> service.setRegistry(registry); // 多个注册中心可以用setRegistries()
> service.setProtocol(protocol); // 多个协议可以用setProtocols()
> service.setInterface(IQueryUserInfoService.class);
> service.setRef(xxxService);
> service.setVersion("1.0.0");
> // 暴露及注册服务
> service.export();
> System.out.println(service.getExportedUrls());Consumer:ReferenceConfig
> reference = build(registryUrl, dubboElementTuple.serviceName,
> dubboElementTuple.groupName, dubboElementTuple.version);
> reference.get();