Import SOFA middleware

更新时间:
复制 MD 格式

To import SOFA middleware into a SOFABoot application, you must configure the following items in your project files:

  1. Add properties to the application.properties file.

  2. In the main pom.xml file, import the starters for the required middleware services.

Properties configuration items

The following properties must be configured in the app/web/src/main/resources/config/application.properties file of your web project:

  • Run mode: run.mode=NORMAL

  • Environment identity: com.alipay.env=shared

  • Instance identity: com.alipay.instanceid=${real value}

  • AntVIP address: com.antcloud.antvip.endpoint=${real value}

  • Access key ID: com.antcloud.mw.access=${real value}

  • Access key secret: com.antcloud.mw.secret=${real value}

    Warning

    • These parameters are required. If you do not configure them, service registration will fail.

    • Replace the `{real value}` placeholder with the actual value.

    • When you publish to the cloud, set the run mode and environment identity to their default values.

Property descriptions

  • run.mode: Specifies the run mode of the project. The default value is NORMAL.

    The enumeration values are as follows:

    • DEV: Forces local mode for Remote Procedure Call (RPC) routing. In this mode, the client and server run on the same machine.

    • TEST: Forces the use of the address specified by the test-url parameter for RPC routing. This creates a point-to-point connection.

    • NORMAL: Uses software load balancing for RPC routing. This is the correct mode for online environments.

  • com.alipay.env: Specifies the environment identity. The default value is com.alipay.env=shared.

  • com.alipay.instanceid: Provides a unique identity for the middleware instance to distinguish it from other users' instances.

  • com.antcloud.antvip.endpoint: Middleware uses AntVIP for addressing. In a distributed environment, an application uses a polling policy to find the server-side of each component using the internal network IP address specified by AntVIP. The AntVIP addresses for different environments are as follows.

    • China (Hangzhou) Finance: cn-hangzhou-fin-middleware-acvip-prod.cloud.alipaycs.net

    • China (Shanghai): cn-shanghai-middleware-acvip-prod.cloud.alipaycs.net

    • Shanghai Gold Zone: cn-shanghai-fin-sofastack-middleware-acvip-prod.cloud.alipaycs.net

    • China (Hangzhou): cn-hangzhou-middleware-acvip-prod.cloud.alipaycs.net

  • com.antcloud.mw.access: Access key ID.

  • com.antcloud.mw.secret: Access key secret.

Configuration steps

To configure these properties, follow these steps:

  1. Log on to the SOFAStack console.

  2. In the navigation pane on the left, choose Middleware > Overview.

    Retrieve the following information:

    • instanceId (instance identity): The unique identity of the application instance in the workspace. The corresponding key in the application is com.alipay.instanceid.

    • AntVIP endpoint: The application uses AntVIP to retrieve the server-side addresses of each component. Each region has a unique address. The corresponding key in the application is com.antcloud.antvip.endpoint. For the AntVIP addresses in different environments, see Property descriptions.

  3. Click your profile picture in the upper-right corner of the console, and then click AccessKey Management. On the page that appears, you can retrieve the values for the access control properties. The corresponding keys in the application are as follows:

    • Access Key ID: com.antcloud.mw.access

    • Access Secret: com.antcloud.mw.secret

      Note

      To create an AccessKey, you can click Get AK. For more information, see Create an AccessKey.

  4. Configure the run mode and environment. For example:

    run.mode=NORMAL
    com.alipay.env=shared
  5. You can configure these property keys and values in the application.properties file.

Import starters for middleware services

SOFABoot manages the versions of all imported middleware services. You can import a middleware service by adding or modifying its starter in the main pom.xml file.

The dependencies for middleware services and their starters are as follows:

  • groupId: com.alipay.sofa.

  • version: Starting from SOFABoot 3.2.1, the middleware starter version is the same as the SOFABoot version. For the latest version information, see Version Guide.

  • artifactId: The name of the starter. For more information, see the following table.

    Middleware

    artifactId

    Product

    Microservice

    SOFARPC

    rpc-enterprise-sofa-boot-starter

    Dynamic Configuration

    ddcs-enterprise-sofa-boot-starter

    Throttling and Circuit Breaking

    guardian-sofa-boot-starter

    SOFABoot

    Module Isolation

    isle-enterprise-sofa-boot-starter

    Task Scheduling

    scheduler-enterprise-sofa-boot-starter

    Message Queue

    sofamq-enterprise-sofa-boot-starter

    Distributed Tracing

    tracer-enterprise-sofa-boot-starter

    Distributed Transaction

    dtx-enterprise-sofa-boot-starter

    Cross-product

    Security

    security-enterprise-sofa-boot-starter

    SOFA Runtime

    runtime-enterprise-sofa-boot-starter

    Health Check

    healthcheck-enterprise-sofa-boot-starter


View starter information

Follow these steps to quickly retrieve the dependencies and versions of each middleware starter imported by SOFABoot:

  1. Enable the health check feature in your application.

    • A SOFABoot project created by following the instructions in Create a project has the health check feature enabled by default because other components have already imported it.

    • If it is not enabled, see Import health check for instructions.

  2. In a browser, go to http://localhost:8080/actuator/versions to view information about the middleware starters. The following code provides an example:

    [
            {
                GroupId:"com.alipay.sofa",
                Doc-Url:"https://www.cloud.alipay.com/docs/2/56003",
                ArtifactId:"rpc-enterprise-sofa-boot-starter",
                Commit-Time:"2020-02-20T16:53:47+0800",
                Commit-Id:"fdfaded104aafe578a3e3b741a4cedaaf07e3c26",
                Version:"3.3.0",
                Build-Time:"2020-02-20T17:00:19+0800"
            },
            ...
    ]