Registry routing
When you use software load balancing, a consumer discovers services from a registry. By default, the Ant Group DSR registry is used, but you can also manually specify a registry for a service.
Registries
The following registries are supported:
Registry alias | Registry name | |
Standard registries | dsr | Ant Registry (Enterprise Edition) |
sofa | Ant Registry (Open Source Edition) | |
consul | Open source Consul registry | |
zookeeper | Open source ZooKeeper registry | |
nacos | Open source Nacos registry | |
Special registries | mesh | Mesh pattern, uses Ant MOSN |
gateway | Gateway pattern, uses gateway service discovery | |
local | Local pattern, used for local testing | |
multicast | Broadcast pattern | |
Configuration methods
Specify a default registry for global services
To specify a registry for global services, add the following parameters to the
application.propertiesfile or as startup parameters.NoteYou can only set the default registry for global services to DSR, local pattern, or Mesh pattern.
Use the DSR registry by default
run.mode=normalUse the local pattern by default
run.mode=devUse the Mesh pattern
MOSN_ENABLE=true
Specify a registry for a single service
To specify a registry for a single service, add the
<sofa:global-attrs registry="<registry alias>" />field to the code that publishes and subscribes to the service. For example:<bean id="helloSyncServiceImpl" class="com.alipay.sofa.rpc.samples.invoke.HelloSyncServiceImpl"/> <sofa:service ref="helloSyncServiceImpl" interface="com.alipay.sofa.rpc.samples.invoke.HelloSyncService"unique-id=""> <sofa:binding.bolt> <sofa:global-attrs registry="mesh" /> </sofa:binding.bolt> </sofa:service>