Subscription only, direct connection to provider

Direct connection provider
(+) (#)

In the development and testing environment, it is often necessary to bypass the registration center and only test the specified service provider. In this case, point-to-point direct connection may be required. The point-to
-point direct connection method will be based on the service interface. , ignoring the provider list of the registry center, the
point-to-point configuration of the A interface does not affect the B interface obtaining the list from the registry center.



(1) If the online demand requires point-to-point, you can configure the url to point to the provider in <dubbo:reference>, which will bypass the registration center, and separate multiple addresses with semicolons. The configuration is as follows: (version 1.0.6 and above Support)

<dubbo:reference id="xxxService" interface="com.alibaba.xxx.XxxService" url="dubbo://localhost:20890" />
(2) Add the -D parameter to the JVM startup parameter to map the service address , such as:
(key is the service name, value is the service provider url, this configuration has the highest priority, and is supported by version 1.0.15 and above)

java -Dcom.alibaba.xxx.XxxService=dubbo://localhost:20890
Note
In order to avoid To complicate the online environment, do not use this function online, it should only be used in the testing phase.
(3) If there are many services, you can also use file mapping, such as:
(Use -Ddubbo.resolve.file to specify the mapping file path, this configuration has a higher priority than the configuration in <dubbo:reference>, version 1.0.15 and above Supported)
(version 2.0 and above automatically loads ${user.home}/dubbo-resolve.

java -Ddubbo.resolve.file=xxx.properties
and then add in the mapping file xxx.properties:
(key is the service name, value is the service provider url)

com.alibaba.xxx.XxxService=dubbo://localhost:20890
Note
To avoid complicating the online environment, do not use this feature online, it should only be used in the testing phase.
Only subscription
(+) (#)

problem
In order to facilitate development and testing, a registration center where all services are available is often shared offline. At this time, if a service provider under development is registered, it may affect the normal operation of consumers.
Solution The service provider developer
can only subscribe to the service (the developed service may depend on other services) without registering the service under development, and test the service under development through direct connection.


To disable registration configuration:

<dubbo:registry address="10.20.153.10:9090" register="false" />
or:

<dubbo:registry address="10.20.153.10:9090?register=false" />

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326726713&siteId=291194637