dubbo:service element

The configuration of the service provider. The corresponding class is org.apache.dubbo.config.ServiceConfig.

AttributeCorresponding URL parameterTypeRequiredDefault ValueFunctionDescriptionCompatibility
interfaceclassTrueService discoveryThe service interface nameAbove 1.0.0
refobjectTrueService discoveryThe reference to the service implementationAbove 1.0.0
versionversionstringFalse0.0.0Service discoveryService version. It’s recommended to use 2 digitals such as 1.0. It’s necessary to upgrade version only when the service is not compatible.Above 1.0.0
groupgroupstringFalseService discoveryThe group of the service providers. It can distinguish services when it has multiple implements.Above 1.0.7
path<path>stringFalsedefault value is the interface nameService discoveryIn 1.0, service path is not supported, it’s always equals to the interface name. So it may not compitable when a service reference in 1.0 calls a service provider in 2.0 that specified path.Above 1.0.12
delaydelayintFalse0Performance optimizeThe delay time(ms) for registering services. When set to -1, it indicates that the services will expose to registry after the Spring context is initializedAbove 1.0.14
timeouttimeoutintFalse1000Performance optimizeThe RPC timeout(ms)Above 2.0.0
retriesretriesintFalse2Performance optimizeThe retry count for RPC, not including the first invoke. Please set it to 0 if don’t need to retry.Above 2.0.0
connectionsconnectionsintFalse100Performance optimizeThe maximum connections of every provider. For short connection such as rmi, http and hessian, it’s connection limit, but for long connection such as dubbo, it’s connection count.Above 2.0.0
loadbalanceloadbalancestringFalserandomPerformance optimizeStrategy of load balance, random, roundrobin and leastactive are available.Above 2.0.0
asyncasyncbooleanFalsefalsePerformance optimizeAsynchronous execution, not reliable. It does not block the execution thread just only ignores the return value.Above 2.0.0
locallocalclass/booleanFalsefalseService governancetrue means use the default proxy class name, which is the interface name with Local as the suffix. But it has been marked as @Deprecated.Pleas see also stub.Above 2.0.0
stubstubclass/booleanFalsefalseService governancetrue means use the default proxy class name, which is the interface name with Stub as the suffix. It’s used to execute local logic such as caching. The proxy class must have a constructor with the remote proxy object as a parameter, such as public XxxServiceStub(XxxService xxxService)Above 2.0.0
mockmockclass/booleanFalsefalseService governancetrue means use the default mock class name, which is the interface name with Mock suffix. It’s called when the RPC is failed, such as timeout or IO exception. The mock class must carry a none parameter constructor. The difference between mock and local proxy is that local proxy is always invoked before RPC but mock is invoked only when exception after RPC.Above 2.0.0
tokentokenstring/booleanFalsefalseService governanceEnable token validation. Disable token if it’s null. It will generate token randomly when enable, or will use static token. The token is designed to prevent consumers from bypassing the registry direct access to provider. If you want peer to peer, token validation must disbable.Above 2.0.0
registrystringFalseregister to all registries by defaultConfiguration associationRegister services to specified registry while having multiple registries. It is the id value of the <dubbo:registry>. If don’t want to register to any registry, set it as N/AAbove 2.0.0
providerstringFalseuse the first configured providerConfiguration associationThe reference to <dubbo:provider>Above 2.0.0
deprecateddeprecatedbooleanFalsefalseService governanceMark the service is deprecated. If true, there will log an error log on the client side.Above 2.0.5
dynamicdynamicbooleanFalsetrueService governanceWhether the service is registered dynamically. If false, services will be showed as disable, you need to enable it manually. And you also need to disable it when provider shut down.Above 2.0.5
accesslogaccesslogstring/booleanFalsefalseService governancetrue will write access log to logger. Specifying it to a log path, you can write access logs to special log file.Above 2.0.5
ownerownerstringFalseService governanceThe owner of the service. It’s used for service governance.Above 2.0.5
documentdocumentstringFalseService governanceService document URLAbove 2.0.5
weightweightintFalsePerformance optimizeThe weight of the serviceAbove 2.0.5
executesexecutesintFalse0Performance optimizeThe maximum parallel execution request count per method per service for the provider.Above 2.0.5
proxyproxystringFalsejavassistPerformance optimizeThe proxy implement, jdk/javassist are available.Above 2.0.5
clusterclusterstringFalsefailoverPerformance optimizefailover/failfast/failsafe/failback/forking are available.Above 2.0.5
filterservice.filterstringFalsedefaultPerformance optimizeThe filter name of the RPC process of the provider, use , to separate multiple filter names.Above 2.0.5
listenerexporter.listenerstringFalsedefaultPerformance optimizeThe listener name of the provider, use , to separate multiple listener names.
protocolstringFalseConfiguration associationSpecify the protocol for service provider. It references the id of <dubbo:protocol> tag. Use , to separate multiple protocols.Above 2.0.5
layerlayerstringFalseService governanceThe biz layer of the service provider, such as biz, dao, intl:web and china:acton.Above 2.0.7
registerregisterbooleanFalsetrueService governanceWhether registering service providers to registry.Above 2.0.8

Last modified December 22, 2020: clean up website (6e41905afab)