To import SOFA middleware into a SOFABoot application, you must configure the following items in your project files:
Add properties to the
application.propertiesfile.In the main
pom.xmlfile, 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=NORMALEnvironment identity:
com.alipay.env=sharedInstance 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}WarningThese 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 isNORMAL.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 iscom.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.netChina (Shanghai):
cn-shanghai-middleware-acvip-prod.cloud.alipaycs.netShanghai Gold Zone:
cn-shanghai-fin-sofastack-middleware-acvip-prod.cloud.alipaycs.netChina (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:
Log on to the SOFAStack console.
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.
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.accessAccess Secret:
com.antcloud.mw.secretNoteTo create an AccessKey, you can click Get AK. For more information, see Create an AccessKey.
Configure the run mode and environment. For example:
run.mode=NORMAL com.alipay.env=sharedYou can configure these property keys and values in the
application.propertiesfile.
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
rpc-enterprise-sofa-boot-starter
ddcs-enterprise-sofa-boot-starter
guardian-sofa-boot-starter
SOFABoot
isle-enterprise-sofa-boot-starter
scheduler-enterprise-sofa-boot-starter
sofamq-enterprise-sofa-boot-starter
tracer-enterprise-sofa-boot-starter
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:
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.
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" }, ... ]