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
Situation Awareness
Managed Threat Detection
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
Help Center/ Cloud Service Engine/ Getting Started/ Connecting Spring Cloud Applications to ServiceComb Engines Using Spring Cloud Huawei SDK

Connecting Spring Cloud Applications to ServiceComb Engines Using Spring Cloud Huawei SDK

Updated on 2024-09-30 GMT+08:00

This section uses a demo to demonstrate how to connect a Spring Cloud application to a ServiceComb engine Using Spring Cloud Huawei SDK.

  1. Preparations

    You need to register with Huawei Cloud and complete real-name authentication, top up your account, grant permissions, create a VPC and subnet, obtain the demo package, and prepare the local host for compilation, building, and packaging.

  2. Creating a ServiceComb Engine

    You can select engine specifications, AZs, and networks when creating an engine.

  3. Connecting Spring Cloud Applications to ServiceComb Engines

    This section describes how to connect a provider service and a consumer service to a ServiceComb engine.

Preparations

  1. Sign up for a HUAWEI ID and complete real-name authentication.
    Skip this step if you already have a HUAWEI ID, or perform the following steps to create one.
    1. Log in to the Huawei Cloud official website and click Sign Up.
    2. Sign up for a HUAWEI ID. For details, see Signing up for a HUAWEI ID and Enabling Huawei Cloud Services.

      After your ID is created, the system redirects you to your personal information page.

    3. Complete real-name authentication. For details, see Individual Real-Name Authentication.
      NOTE:

      Real-name authentication is required only when you buy or use resources in the Chinese mainland.

  2. Top up your account.

    Ensure that your account has sufficient balance.

  3. Grant permissions.

    You must have the required permissions to create dependent resources and ServiceComb engines. For details, see Creating a User and Granting Permissions.

  4. Create a VPC and subnet.

    ServiceComb engines run in a VPC and need to be bound to a subnet. You must have a VPC and subnet to create ServiceComb engines. For details, see Creating a VPC. Skip this step if you already have a VPC and subnet.

  5. The Java JDK and Maven have been installed on the local host for compilation, building, and packaging, and the Maven central library can be accessed.
  6. Download the demo source code from GitHub to the local host and decompress it.
    NOTE:

    Spring Cloud Huawei has been integrated in the configuration file of this demo. For details, see Connecting Spring Cloud Applications to ServiceComb Engines.

Creating a ServiceComb Engine

  1. Go to the Buy Exclusive ServiceComb Engine page.
  2. Set parameters according to the following table. Parameters marked with an asterisk (*) are mandatory. For details, see Creating a ServiceComb Engine.

    Table 1 Creating a ServiceComb engine

    Parameter

    Description

    *Billing Mode

    Billing mode. Currently, Pay-per-use is supported. Pay-per-use is postpaid. You use ServiceComb engines and then pay as billed for your usage duration.

    *Enterprise Project

    Select the enterprise project where the ServiceComb engine locates. Enterprise projects let you manage cloud resources and users by project. default is selected by default.

    *Instances

    Select the engine specifications. In this example, select 100 microservice instances.

    *Engine Type

    If the engine type is cluster, the engine is deployed in cluster mode and supports host-level DR.

    *Name

    Enter a ServiceComb engine name. The name contains 3 to 64 characters, including letters, digits, and hyphens (-), and starts with a letter but cannot end with a hyphen (-). For example, cse-test.

    *AZ

    Select one or three AZs. In this example, select one AZ to provide host-level DR.

    *Network

    Select the created VPC and subnet. You can search for and select a VPC and subnet from the drop-down list.

    Description

    Click and enter the engine description, for example, create a ServiceComb engine.

    *Security Authentication

    The exclusive ServiceComb engine with security authentication enabled provides the system management function using the role-based access control (RBAC) through the microservice engine console. In this example, disable security authentication. You can enable it after the instance is created.

  3. Click Buy. The page for confirming the engine information is displayed.
  4. Click Submit and wait until the engine is created.

    NOTE:
    • It takes about 31 minutes to create a microservice engine.
    • After the microservice engine is created, its status is Available. For details about how to view the microservice engine status, see Viewing ServiceComb Engine Information.
    • If the microservice engine fails to be created, view the failure cause on the Operation page and rectify the fault. Then, you can perform the following operations:
      • In the Microservice Engine Information area, click Retry to create a microservice engine again.
      • If the retry fails, delete the microservice engine that fails to be created. For details, see Deleting an Exclusive ServiceComb Engine.

Connecting Spring Cloud Applications to ServiceComb Engines

  1. Log in to CSE.
  2. Choose Exclusive ServiceComb Engine.
  3. Click the ServiceComb engine created in Creating a ServiceComb Engine.
  4. Obtain the service center address and configuration center address of the ServiceComb engine.

    In the Service Discovery and Configuration area, you can view the service center address and configuration center address of the microservice engine.

  5. Change the addresses of the registry center and configuration center in the demo.

    1. In the directory of the demo source code downloaded to the local host, find the \basic\consumer\src\main\resources\bootstrap.yml and \basic\provider\src\main\resources\bootstrap.yml files.
    2. Add the service center address and configuration center address of the ServiceComb engine to the project configuration file (\basic\consumer\src\main\resources\bootstrap.yml is used as an example).
      spring:
        application:
          name: basic-consumer
        cloud:
          servicecomb:
            discovery:
              enabled: true
              watch: false
              # Registry center address
              address: https://192.168.0.210:30100,https://192.168.0.246:30100
              appName: basic-application
              serviceName: ${spring.application.name}
              version: 0.0.1
              healthCheckInterval: 30
            config:
              # Configuration center address
              serverType: kie
              serverAddr: https://192.168.0.210:30110,https://192.168.0.246:30110
      NOTE:

      In the ServiceStage deployment scenario, the service registry center and configuration center addresses are automatically injected during the deployment. You do not need to manually add them.

  6. Pack the demo source code into a JAR package.

    1. In the root directory of the demo source code, open the Command Prompt and run the mvn clean package command to package and compile the project.
    2. After the compilation is successful, two JAR packages are generated, as shown in Table 2.
      Table 2 Software packages

      Directory Where the Software Package Is Located

      Package Name

      Description

      basic\consumer\target

      basic-consumer-1.0-SNAPSHOT.jar

      Service consumer

      basic\provider\target

      basic-provider-1.0-SNAPSHOT.jar

      Service provider

  7. Deploy the application.

    Deploy provider and consumer on ServiceStage.
    1. Upload the JAR package generated in 6 to OBS.
    2. Create a CCE cluster in the same VPC as the ServiceComb engine instance. For details, see Creating a Kubernetes Cluster.
    3. Create a ServiceStage environment in the VPC where the engine instance is located, and manage the ServiceComb engine and CCE resource. For details, see Creating an Environment.
    4. Deploy provider and consumer. For details, see Creating and Deploying a Component.

  8. Confirm the deployment results.

    1. Optional: On the CSE console, choose Exclusive ServiceComb Engine and click the ServiceComb engine created in Creating a ServiceComb Engine.
    2. Choose Microservice Catalog > Microservice List to view the number of basic-consumer and basic-provider microservice instances.
      • If Instances is not 0, the demo has been connected to the ServiceComb engine.
      • If Instances is 0 or the basic-consumer and basic-provider services cannot be found, the demo fails to be connected to the microservice engine.

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