To help you better use a Microservices Engine (MSE) instance, you can learn about the items that you must take note of when you create an MSE instance and get familiar with the configuration code when you develop Spring Cloud applications and Dubbo applications.
Create an instance
When you create an MSE instance, you must specify a network type, a region, and public bandwidth. Take note of the following points when you specify these items:
Network type
Virtual private cloud (VPC): The VPC that you select must be the same as the VPC of the Elastic Compute Service (ECS) instance where your application resides.
Internet: If your application needs to access the MSE instance over the Internet, you must configure an IP address whitelist. CIDR blocks in the IP address whitelist must be in the Public IP address of an ECS instance/32 format. For more information, see Configure a public IP address whitelist.
Region
If you select VPC as the network type, the region that you select must be the same as the region of the ECS instance where your application resides.
Public bandwidth
If your application needs to access the MSE instance over the Internet, you must configure the public bandwidth. A public endpoint is generated only if the public bandwidth is greater than 0.
Use registries
MSE provides multiple types of registries, such as Nacos registries, Eureka registries, and ZooKeeper registries, to help you manage Spring Cloud applications and Dubbo applications. For more information, see Nacos.
Nacos
Sample code of an MSE Nacos registry for Spring Cloud applications
spring.application.name=service-provider server.port=18081 spring.cloud.nacos.discovery.server-addr=mse-XX-p.nacos-ans.mse.aliyuncs.com:8848 # mse-XX-p.nacos-ans.mse.aliyuncs.com is the public endpoint of the Nacos instance that is created on MSE. # If you want to use a namespace that you created, use the following configuration: #spring.cloud.nacos.discovery.namespace=11a8ca4c-xxx-xxx-xxx-6aad4dab92a9
Sample code of an MSE Nacos registry for Dubbo applications
Use XML files
<dubbo:application name="demo-provider"/> <dubbo:protocol name="dubbo" port="28082" /> <dubbo:service interface="com.alibaba.dubbo.api.IHelloService" ref="helloService"/> <bean id="helloService" class="com.alibaba.dubbo.service.impl.IHelloServiceImpl"/> <dubbo:registry address="nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848"/> # mse-XX-p.nacos-ans.mse.aliyuncs.com is the public endpoint of the Nacos instance that is created on MSE. # If you want to use a namespace that you created, use the following configuration: #<dubbo:registry address="nacos://mse-XX.nacos-ans.mse.aliyuncs.com:8848?namespace=d5cbb70a5-xxx-xxx-84c1-d43479ae0932"/>
Use .properties files
dubbo.application.name=dubbo-consumer-demo server.port=8080 dubbo.registry.address=nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848 # mse-XX-p.nacos-ans.mse.aliyuncs.com is the public endpoint of the Nacos instance that is created on MSE. # If you want to use a namespace that you created, use the following configuration: dubbo.registry.parameters.namespace=5cbb70a5-xxx-xxx-xxx-d43479ae0932
<dubbo:application name="demo-provider"/> <dubbo:protocol name="dubbo" port="28082" /> <dubbo:service interface="com.alibaba.dubbo.api.IHelloService" ref="helloService"/> <bean id="helloService" class="com.alibaba.dubbo.service.impl.IHelloServiceImpl"/> <dubbo:registry address="nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848"/>
ZooKeeper
Sample code of an MSE ZooKeeper registry for Spring Cloud applications
spring: application: name: demo-provider cloud: zookeeper: connect-string: mse-XX-p.nacos-ans.mse.aliyuncs.com:2181 discovery: enabled: true
Sample code of an MSE ZooKeeper registry for Dubbo applications
<dubbo:registry address="zookeeper://mse-XX-p.nacos-ans.mse.aliyuncs.com:2181" />
Eureka
Sample code of an MSE Eureka registry for Spring Cloud applications
server:
port: 8080
spring:
application:
name: demo-provider
eureka:
client:
serviceUrl:
defaultZone: http://mse-XXX-p.eureka.mse.aliyuncs.com:8761/eureka
instance:
prefer-ip-address: true
For sample code of configuration centers, see Java SDK.
Troubleshoot issues in Nacos registries
If an issue occurs when you use an MSE Nacos registry, you can view the Nacos client logs in the naming.log file in the ${user.home}/logs/nacos/
directory.