This topic describes the key configuration classes for Remote Procedure Call (RPC). You can use these classes for your development.
ProviderConfig
Property | Default value | Description |
id | Automatically generated | ID |
application | Empty ApplicationConfig | Set the application object. |
interfaceId | - | Set the service interface. This is a unique identifier element. Set this to the actual interface class for both regular and callback invocations. |
uniqueId | - | Set the service tag. This is a unique identifier element. |
filterRef | - | The filter configuration instance. List |
filter | - | The filter configuration alias. List. Separate multiple aliases with commas (,). |
registry | - | Set the server-side registry. List |
methods | - | The method-level configuration. Format: |
serialization | hessian2 | Set the serialization protocol. |
register | true | Specifies whether to register the service. This setting may not take effect, depending on the implementation. |
subscribe | true | Specifies whether to subscribe to the service. This setting may not take effect, depending on the implementation. |
proxy | javassist | Set the proxy type. Supported types are javassist and JDK dynamic proxy. |
ref | - | The service interface implementation class. |
server | - | The server. List. Lets you publish to multiple servers at once. |
delay | 0 | Set the delay for publishing the service. Set to -1 to publish after Spring has finished loading. This setting is only effective when using Spring. |
weight | - | Set the static weight of the service. |
include | - | A list of methods to publish. Separate multiple methods with commas (,). For example:
|
exclude | - | A list of methods not to publish. Separate multiple methods with commas (,). For example:
|
dynamic | true | Specifies whether the registration is dynamic. If set to false, the service is not automatically published. You must publish it manually from the management console. |
priority | - | Set the service priority. The higher the value, the higher the priority. |
bootstrap | bolt | Set the bootstrap for publishing the service. |
executor | - | Set a custom thread pool. |
timeout | - | Set the server-side execution timeout. Unit: ms. A timeout does not interrupt the execution thread. It only logs a warning. |
concurrents | - | Set the maximum number of concurrent requests for each method in the interface. Valid values:
|
cacheRef | - | The result cache implementation class. |
mockRef | - | The Mock implementation class. |
mock | - | Specifies whether to enable Mock. |
validation | - | Specifies whether to enable parameter validation, based on JSR 303. |
compress | false | Specifies whether to enable compression. |
cache | false | Specifies whether to enable the result cache. |
parameters | - | Extra properties. Format: |
ConsumerConfig
Property | Default value | Description |
id | Automatically generated | ID |
application | Empty ApplicationConfig | Set the application object. |
interfaceId | - | Set the service interface. This is a unique identifier element. Set this to the actual interface class for both regular and callback invocations. |
uniqueId | - | Set the service tag. This is a unique identifier element. |
filterRef | - | Set the filter configuration instance. List |
filter | - | Set the filter configuration alias. List. Separate multiple aliases with commas (,). |
registry | - | Set the server-side registry. List |
methods | - | The method-level configuration. Format: |
serialization | hessian2 | Set the serialization protocol. |
register | true | Specifies whether to register the service. This setting may not take effect, depending on the implementation. |
subscribe | true | Specifies whether to subscribe to the service. This setting may not take effect, depending on the implementation. |
proxy | javassist | Set the proxy type. Supported types are javassist and JDK dynamic proxy. |
protocol | bolt | Set the invocation protocol. Supported protocols include bolt, rest, and dubbo. |
directUrl | Set the endpoint in direct connection mode. This is used for registration after a direct connection is established. | |
generic | false | Specifies whether to use generalized calls. |
connectTimeout | 1000 | Set the connection timeout. Unit: ms. |
disconnectTimeout | 10000 | Set the timeout for waiting to disconnect. Unit: ms. |
cluster | failover | Set the cluster mode. |
connectionHolder | all | Set the connection manager implementation. |
loadBalancer | random | Set the load balancing algorithm. |
lazy | false | Specifies whether to delay establishing a persistent connection. The connection is created on the first call. |
sticky | false | Specifies whether to use sticky connections. If set to true, the load balancing algorithm is skipped and the last used address is reused. A new address is selected only after the current connection is lost. |
inJVM | true | Specifies whether to convert to a Java Virtual Machine (JVM) call. If set to true, the service provider is discovered by the JVM, and the local configuration is used. |
check | false | Specifies whether to check for strong dependencies. If set to true, startup fails if no active server is available. |
heartbeat | 30000 | Set the heartbeat interval for the client to send to the server. This setting may not take effect, depending on the implementation. |
reconnect | 10000 | Set the interval for the client to re-establish a persistent connection. This setting may not take effect, depending on the implementation. |
router | - | Set the router configuration alias. List |
routerRef | - | Set the router configuration instance. List |
bootstrap | bolt | You can configure the service reference starter. |
addressWait | -1 | Set the time to wait to obtain an address. This setting may not take effect, depending on the implementation. |
timeout | 3000 | Set the invocation timeout. Unit: ms. |
retries | 0 | Set the number of retries after a failure. This is related to the cluster mode. The failover mode reads this parameter. |
invokeType | sync | Set the invocation type. Valid values:
|
onReturn | - | The maximum number of concurrent requests for each method in the interface. Valid values:
|
cacheRef | - | The result cache implementation class. |
mockRef | - | The Mock implementation class. |
cache | false | Specifies whether to enable the result cache. |
mock | - | Specifies whether to enable Mock. |
validation | - | Specifies whether to enable parameter validation, based on JSR 303. |
compress | false | Specifies whether to enable compression. |
parameters | - | Extra properties. Format: |
MethodConfig
Property | Default value | Notes |
name | - | Set the method name. This cannot be used for overloaded methods. |
timeout | - | Set the invocation timeout. Unit: ms. |
retries | - | Set the number of retries after a failure. |
invokeType | - | Set the invocation type. Valid values:
|
validation | - | Specifies whether to enable parameter validation, based on JSR 303. |
onReturn | - | The SofaResponseCallback to invoke on return. Used to implement features such as callbacks. |
concurrent | - | The maximum number of concurrent requests for each method in the interface. Valid values:
|
validation | - | Specifies whether to enable parameter validation. |
compress | - | Specifies whether to enable compression. |
parameters | - | Extra properties. Format: |
ServerConfig
Property | Default value | Notes |
protocol | bolt | The invocation protocol. Supported protocols include bolt, rest, and dubbo. |
host | 0.0.0.0 | The actual IP address to listen on. This corresponds to the address of a network interface controller (NIC). |
port | 12200 | The port for the protocol. The default ports are as follows:
|
contextPath | - | Set the context path. |
ioThreads | 0 | Set the number of I/O threads. This setting may not take effect, depending on the implementation. For example, the default number of threads for Bolt is the number of CPU cores × 2. A value of 0 means the number is calculated automatically. |
threadPoolType | cached | Set the business thread pool type. |
coreThreads | 20 | Set the core size of the business thread pool. |
maxThreads | 200 | Set the maximum size of the business thread pool. |
telnet | true | Specifies whether to allow Telnet. This setting may not take effect, depending on the implementation. For example, Bolt does not support Telnet. |
queueType | normal | Set the business thread pool type. This can be used to implement features such as priority queues. |
queues | 0 | Set the business thread pool queue. |
aliveTime | 60000 | Set the time to live for the business thread pool. Unit: ms. |
preStartCore | - | Specifies whether to initialize core threads. |
accepts | 100000 | Set the maximum number of persistent connections. This setting may not take effect, depending on the implementation. |
serialization | hessian2 | Set the serialization protocol. |
virtualHost | - | Set the virtual host address. This address is prioritized when registering with the registry. |
virtualPort | - | Set the virtual host port. This port is prioritized when registering with the registry. |
epoll | false | Specifies whether to enable epoll. This setting may not take effect, depending on the implementation. |
daemon | true | Specifies whether to enable port protection. The valid values are as follows:
|
adaptivePort | false | Specifies whether to adjust the port. If set to true and the port is in use, the system automatically tries the next port number (port + 1). |
transport | netty4 | The transport-layer implementation. This setting may not take effect, depending on the implementation. |
autoStart | true | Specifies whether to automatically start the port. |
stopTimeout | 20000 | Set the graceful shutdown timeout. Unit: ms. |
boundHost | - | The address to bind to. By default, this is the value of `host`. |
parameters | - | Extra properties. Format: |
RegistryConfig
Property | Default value | Notes |
protocol | zookeeper | The service protocol. Supported protocols are zookeeper and local. |
address | - | Specify the registry address. Configure either the `address` or the `index` property. |
index | - | Specify the address of the registry's addressing service. Configure either the `address` or the `index` property. |
register | true | Specifies whether to register the service. |
subscribe | true | Specifies whether to subscribe to the service. |
timeout | 10 | The timeout for calling the registry. Unit: seconds. |
connectTimeout | 20 | The timeout for connecting to the registry. Unit: seconds. |
file | $HOME | The location of the local file used by the `local` protocol. The default location is |