Check here full sample code
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>3.0.9</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-openapi</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>2.0.0</version>
</dependency>
<dubbo:config-center address="apollo://localhost:8080"/>
or
dubbo
config-center
address: apollo://localhost:8080
or
dubbo.config-center.address=apollo://localhost:8080
or
ConfigCenterConfig configCenter = new ConfigCenterConfig();
configCenter.setAddress("apollo://localhost:8080");
A core concept in Apollo is the namespace - namespace, which is different from the namespace concepts of Zookeeper and Nacos above, so the usage method is also special. It is recommended to read the following documents after fully understanding the usage of Apollo itself.
But in general, for the adaptation of Apollo:
<dubbo:config-center group="demo-provider" address="apollo://localhost:8080"/>
The group
of config-center determines where Apollo reads the externalized configuration dubbo.properties
file:
dubbo
namespace by default, and the user must write the externalized configuration under the dubbo
namespace.For example, the following example uses the default global externalization configuration of group=‘dubbo’, that is, the configuration can be read by all applications.
If the configuration group=‘application name’ is an application-specific configuration, only this application can read it.
Regarding externalized file configuration hosting, it is equivalent to storing the contents of the
dubbo.properties
configuration file in Apollo. Each application can inherit the public configuration by associating with the shareddubbo
namespace, and then can override individual configuration items individually.
**Traffic governance rules must be shared globally, so the namespace configuration in each application should be consistent. **
<dubbo:config-center namespace="governance" address="apollo://localhost:8080"/>
The namespace
of config-center determines where Apollo accesses traffic governance rules
:
dubbo
namespace by default, and the governance rules must be written under the dubbo
namespace.For example, the following example puts the traffic governance rules under the governance
namespace through namespace='governance'
.
Currently Dubbo is adapted to env, apollo.meta, apollo.cluster, apollo.id and other unique configuration items, which can be configured through the extended parameters of config-center.
Such as
dubbo.config-center.address=apollo://localhost:8080
or
dubbo.config-center.prameters.apollo.meta=xxx
dubbo.config-center.prameters.env=xxx