هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Using the Configuration Center in Java Chassis

Updated on 2024-08-14 GMT+08:00
  • Java chassis uses the configuration center named config-center.

    You need to add the following dependencies to the project:

    <dependency>
      <groupId>org.apache.servicecomb</groupId>
      <artifactId>config-cc</artifactId>
    </dependency>

    If the preceding dependencies have been directly or indirectly included in the project, you do not need to add them. Java chassis contains the configuration items listed in Table 1. The values of these configuration items specify the identity of microservices in the configuration center and the interaction between microservices and the configuration center.

    Table 1 Common configuration items of Java chassis

    Item

    Description

    Default Value

    Remarks

    servicecomb.service.application

    Application

    default

    -

    servicecomb.service.name

    Microservice name

    defaultMicroservice

    -

    servicecomb.service.version

    Microservice version

    1.0.0.0

    -

    servicecomb.service.environment

    Environment

    -

    The value is the environment ID. Example value: production or development.

    servicecomb.config.client.serverUri

    Access address. The format is http(s)://{ip}:{port}. Use commas (,) to separate multiple addresses.

    http://127.0.0.1:30103

    config-center

    servicecomb.config.client.tenantName

    Tenant name of the application

    default

    config-center

  • Java chassis uses the configuration center named kie.
    You need to add the following dependencies to the project:
    <dependency>
      <groupId>org.apache.servicecomb</groupId>
      <artifactId>config-kie</artifactId>
    </dependency>

    If the preceding dependencies have been directly or indirectly included in the project, you do not need to add them. Java chassis contains the configuration items listed in Table 2. The values of these configuration items specify the identity of microservices in the configuration center and the interaction between microservices and the configuration center.

    Table 2 Common configuration items of Java chassis

    Item

    Description

    Default Value

    Remarks

    servicecomb.service.application

    Application

    default

    -

    servicecomb.service.name

    Microservice name

    defaultMicroservice

    -

    servicecomb.service.version

    Microservice version

    1.0.0.0

    -

    servicecomb.service.environment

    Environment

    -

    The value is the environment ID. Example value: production or development.

    servicecomb.kie.serverUri

    Address for accessing kie. The format is http(s)://{ip}:{port}. Use commas (,) to separate multiple addresses.

    -

    kie

    servicecomb.kie.firstRefreshInterval

    Interval for updating configuration items for the first time (ms)

    3000

    kie

    servicecomb.kie.refresh_interval

    Interval for updating configuration items (ms)

    3000

    kie

    servicecomb.kie.domainName

    Tenant name of the application

    default

    kie

Java chassis provides multiple methods to read dynamic configurations.
  • The first method is to use the archaius API, for example,
    DynamicDoubleProperty myprop = DynamicPropertyFactory.getInstance()
      .getDoubleProperty("trace.handler.sampler.percent", 0.1);
    

    The archaius API supports callback to process configuration change:

    myprop.addCallback(new Runnable() {
          public void run() {
              // When the value of a configuration item changes, the callback method is invoked.
              System.out.println("trace.handler.sampler.percent is changed!");
          }
      });
    
  • The second method is to use the configuration injection mechanism provided by Java chassis. This method can easily handle complex configurations and configuration priorities. For example,
      @InjectProperties(prefix = "jaxrstest.jaxrsclient")
      public class Configuration {
        /*
         * The prefix attribute override of a method will overwrite @InjectProperties defined in the class.
         * The prefix attribute of an annotation.
         *
         * The keys attribute can be a string array. A smaller subscript indicates a higher priority.
         *
         * The system searches for configuration attributes in the following sequence until the configured configuration attributes are found:
         * 1) jaxrstest.jaxrsclient.override.high
         * 2) jaxrstest.jaxrsclient.override.low
         *
         * Test case:
         * jaxrstest.jaxrsclient.override.high: hello high
         * jaxrstest.jaxrsclient.override.low: hello low
         * Expected result:
         * hello high
         */
        @InjectProperty(prefix = "jaxrstest.jaxrsclient.override", keys = {"high", "low"})
        public String strValue;
    

    Inject configurations.

     ConfigWithAnnotation config = SCBEngine.getInstance().getPriorityPropertyManager()
          .createConfigObject(Configuration.class,
                "key", "k");
    
  • The third method is used when Spring and Spring Boot are integrated. The configuration can be read in the native mode of Spring and Spring Boot, for example, @Value and @ConfigurationProperties. Java chassis applies configuration hierarchy to Spring Environment. Spring and Spring Boot can also read the dynamically configured values and the values in the microservice.yaml file.

    For more information about the read configurations of Java chassis, see the developer guide of the community.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback