apache / apache/dubbo

Support set fixed rmi service port

Open
#6,629 3 comments 0 reactions 0 assignees View on GitHub
help wanted type/proposal
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

Rmi protocal will choose a random port as the service port. Sometimes we need to use a fixed port to ensure it is accessable from other service instance.
Could add a parameter to support setting this port?

Here is my current code to set the service port.

org.apache.dubbo.rpc.protocol.rmi.RmiProtocol

``` java
@Override
protected Runnable doExport(final T impl, Class type, URL url) throws RpcException {
RmiServiceExporter rmiServiceExporter = createExporter(impl, type, url, false);
RmiServiceExporter genericServiceExporter =
createExporter(impl, GenericService.class, url, true);

// Here is the code to set the fixed service port.
String servicePort = System.getProperty("dubbo.protocal.rmi.serviceport");
if (servicePort != null && !servicePort.isEmpty()) {
rmiServiceExporter.setServicePort(Integer.valueOf(servicePort));
}

return new Runnable() {
@Override
public void run() {
try {
rmiServiceExporter.destroy();
genericServiceExporter.destroy();
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
}
}
};
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.