> there is my demo
> `
> public static void main(String[] args) throws IOException {
> //may start multiple main process
> System.out.println("start test......");
> ApplicationConfig application = new ApplicationConfig();
> RegistryConfig registry = new RegistryConfig();
> application.setName("test");
> registry.setAddress("127.0.0.1:2181");
> registry.setProtocol("zookeeper");
> ProtocolConfig protocol = new ProtocolConfig();
> protocol.setName("dubbo");
> //random port, i don't know now
> protocol.setPort(-1);
> protocol.setThreads(200);
> ServiceConfig service1 = new ServiceConfig<>();
> service1.setApplication(application);
> service1.setRegistry(registry);
> service1.setProtocol(protocol);
> service1.setInterface(TestService.class);
> service1.setRef(new TestServiceImpl());
> service1.export();
> // i need get the port, ip and start time as key save to log or mysql now,why 
> need save to mysql ,because when the process crashe, other process can get 
> data related to this key doing aftercare,please tell me how to get port, ip 
> and start time
> 
> ```
>     System.in.read();
> 
> }
> ```
> 
> `

It still depends on actual use case.
In your case shown above, one of the solutions is:

```java
URL url = service1.toUrl();
System.out.println(url.getProtocol() + " => " + url.getPort());
```

result: 

```
dubbo => 20880
```

[ Full content available at: https://github.com/apache/dubbo/issues/5115 ]
This message was relayed via gitbox.apache.org for 
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to