The RMI protocol uses the JDK standard java.rmi.*
implementation, employing a blocking short connection and JDK standard serialization.
Serializable
interface.-Dsun.rmi.transport.tcp.responseTimeout=3000
, refer to the RMI configuration below.It is a set of APIs in Java that support the development of distributed applications, achieving method calls between programs on different operating systems.
Since Dubbo 3, the RMI protocol is no longer embedded in Dubbo and needs to be imported as a separate module.
<dependency>
<groupId>org.apache.dubbo.extensions</groupId>
<artifactId>dubbo-rpc-rmi</artifactId>
<version>3.3.0</version>
</dependency>
java -Dsun.rmi.transport.tcp.responseTimeout=3000
For more RMI optimization parameters, please refer to the JDK Documentation
If the service interface extends the java.rmi.Remote
interface, it can interoperate with native RMI, that is:
If the service interface does not extend the java.rmi.Remote
interface:
com.xxx.XxxService$Remote
, extending the java.rmi.Remote
interface, and expose services via this interface,<dubbo:protocol name="rmi" codec="spring" />
is set, the $Remote
interface will not be generated, and the Spring RmiInvocationHandler
interface will be used to expose services, maintaining Spring compatibility.Define RMI Protocol
<dubbo:protocol name="rmi" port="1099" />
Set Default Protocol
<dubbo:provider protocol="rmi" />
Set Protocol for Specific Service
<dubbo:service interface="..." protocol="rmi" />
Multiple Ports
<dubbo:protocol id="rmi1" name="rmi" port="1099" />
<dubbo:protocol id="rmi2" name="rmi" port="2099" />
<dubbo:service interface="..." protocol="rmi1" />
Spring Compatibility
<dubbo:protocol name="rmi" codec="spring" />
If providing services via RMI for external access, there should be no attack risks in the company’s intranet environment.
If the application relies on the old common-collections package, Dubbo will not depend on this package; please check if your application uses it.
There are deserialization security risks. Please check the application: upgrade commons-collections3 to 3.2.2; upgrade commons-collections4 to 4.1. The new versions of commons-collections resolve this issue.