Two, dubbo configuration
1, configuration guidelines
JVM startup -D
parameters priority, so users can deploy and start rewriting parameters, such as when starting the need to change the port protocol.
XML second, if there is configured in XML, the dubbo.properties
corresponding configuration items is invalid.
When Properties Finally, the equivalent of the default value, only XML is not configured, dubbo.properties
the corresponding configuration items take effect, usually used to share a common configuration, such as the application name.
2, the number of retries
Failure automatic switching, when a failure occurs, retry the other servers, but retry will bring a longer delay. You can retries="2"
set the number of retries (excluding the first).
Number again re-arranged as follows:
<dubbo:service retries="2" />
or
<dubbo:reference retries="2" />
or
<dubbo:reference>
<dubbo:method name="findFoo" retries="2" />
</dubbo:reference>
3, timeout
Due to network or server unreliable results in a call center appears an uncertain state (time-out). To avoid a timeout causes the client resource (thread) hang depleted, you must set the timeout.
1, Dubbo consumer side
Global Timeout Configuration
<dubbo:consumer timeout="5000" />
Specified interface and the specific configuration timeouts
<dubbo:reference interface="com.foo.BarService" timeout="2000">
<dubbo:method name="sayHello" timeout="3000" />
</dubbo:reference>
2, Dubbo server
Global Timeout Configuration
<dubbo:provider timeout="5000" />
Specified interface and the specific configuration timeouts
<dubbo:provider interface="com.foo.BarService" timeout="2000">
<dubbo:method name="sayHello" timeout="3000" />
</dubbo:provider>
3, Configuration Guidelines
dubbo recommended configuration as much as possible on the Provider Consumer-side properties:
- Provider for the service, more clearly than the service consumer service performance parameters, such as calling a timeout, a reasonable number of retries, etc.
- After Provider configuration, not Consumer Provider Configuration value is used, i.e., as a default configuration may Provider Consumer's. Otherwise, use the global settings Consumer Consumer end, which for Provider uncontrollable and often irrational
Configuration of rules covering:
The method is superior to other level configuration interface level, i.e., the priority small Scope
Consumer-side configuration better than global configuration Provider configuration,
Finally, Dubbo Hard Code configuration values (see configuration file)
4, the version number
When a interface, incompatibility upgrade, you can use the version number of the transition, the version number of different services does not refer to each other.
Version can migrate the following steps:
In the low-pressure time period, the first half providers to upgrade to the new version
Then all consumers upgrade to the new version
Then the remaining half of the providers upgrade to the new version
Old versions of the service provider configuration:
<dubbo:service interface="com.foo.BarService" version="1.0.0" />
The new version of the service provider configuration:
<dubbo:service interface="com.foo.BarService" version="2.0.0" />
The old version of the service consumer configuration:
<dubbo:reference id="barService" interface="com.foo.BarService" version="1.0.0" />
The new version of the service consumer configuration:
<dubbo:reference id="barService" interface="com.foo.BarService" version="2.0.0" />
If you do not distinguish between versions, you can configure the following manner:
<dubbo:reference id="barService" interface="com.foo.BarService" version="*" />