Direct Connection Provider

Direct connection method in Dubbo for point-to-point communication

In development and testing environments, it is often necessary to bypass the registry and only test specific service providers. In this case, point-to-point direct connection may be required. The point-to-point direct connection method will ignore the provider list from the registry on a service interface basis. Configuring point-to-point for interface A will not affect interface B from obtaining the list from the registry.

/user-guide/images/dubbo-directly.jpg

If point-to-point communication is needed in a production environment, you can configure the reference node to point to the provider URL, bypassing the registry. Multiple addresses can be separated by semicolons, configured as follows:

Annotation Configuration Method

@DubboReference(url="tri://localhost:50051")
private XxxService xxxService

XML Configuration Method

<dubbo:reference id="xxxService" interface="com.alibaba.xxx.XxxService" url="dubbo://localhost:20890" />

More Configuration Methods

Specify via -D Parameter

Add the -D parameter to the JVM startup parameters to map the service address, such as:

java -Dcom.alibaba.xxx.XxxService=dubbo://localhost:20890

File Mapping

If there are many services, you can also use file mapping by specifying the mapping file path with -Ddubbo.resolve.file, which has a higher priority than the configuration in <dubbo:reference> [^3], such as:

java -Ddubbo.resolve.file=xxx.properties

Then add the configuration in the mapping file xxx.properties, where the key is the service name, and the value is the service provider URL:

com.alibaba.xxx.XxxService=dubbo://localhost:20890