This topic completely describes the SOFARPC service publishing and reference in the SOFABoot framework.
Publish a service
<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="" serialize-type="" filter="" timeout="3000" thread-pool-ref=""
warm-up-time="60000"
warm-up-weight="10" weight="100"/>
</sofa:binding.bolt>
<sofa:binding.rest>
</sofa:binding.rest>
</sofa:service>
Attribute Summarization
Attribute | Function | Default value | Remarks |
---|---|---|---|
id | The ID. | Bean name | |
class | The class. | N/A | |
ref | The service interface implementation class. | ||
interface | The unique service interface ID. | It is set to the actual interface class for both common calls and return calls. | |
unique-id | The unique service tag ID. | ||
filter | The configured filter alias. | Separate multiple aliases with a comma (,). | |
registry | The server registry. | Separate multiple items with a comma (,). | |
timeout | The server execution timeout period. | ||
serialize-type | The serialization protocol. | hessian2, protobuf | |
thread-pool-ref | The thread pool used by the current port of the server. | N/A | |
weight | The static weight of the service. | ||
warm-up-weight | The preloading weight of the service. | ||
warm-up-time | The preloading time. | The unit is millisecond. |
Reference a service
<sofa:reference jvm-first="false" id="helloSyncServiceReference"
interface="com.alipay.sofa.rpc.samples.invoke.HelloSyncService" unique-id="">
<sofa:binding.bolt>
<sofa:global-attrs type="sync" timeout="3000" callback-ref="" callback-class="" address-wait-time="1000"
connect.num="1" check="false" connect.timeout="1000" filter="" generic-interface=""
idle.timeout="1000"
idle.timeout.read="1000" lazy="false" loadBalancer="" registry="" retries="1"
serialize-type="" />
<sofa:route target-url="xxx:12200" />
<sofa:method name="hello" callback-class="" callback-ref="" timeout="3000" type="sync"/>
</sofa:binding.bolt>
</sofa:reference>
Attribute Summarization
Attribute | Function | Default value | Remarks |
---|---|---|---|
id | The ID. | Automatically generated | |
jvm-first | Specifies whether to use local services first. | true | |
interface | The unique service interface ID. | It is set to the actual interface class for both common calls and return calls. | |
unique-id | The unique service tag ID. | ||
type | The call method. | sync | Valid values include Callback, Sync, Future, and Oneway methods. |
filter | The configured filter alias. | List | |
registry | The server registry. | List | |
method | The method-level configuration. | Same as above. | |
serialize-type | The serialization protocol. | hessian2 | |
target-url | The direct connection URL. | Register after direct connection. | |
generic-interface | The generic interface. | ||
connect.timeout | The connection timeout period. | 3000 (cover 5000) | |
connect.num | The number of connections. | 1 | |
idle.timeout | The idle timeout period. | ||
idle.timeout.read | The read idle timeout period. | ||
loadBalancer | The SLB algorithm. | random | |
lazy | Specifies whether to delay the establishment of persistent connection. | false | |
address-wait-time | The waiting time before obtaining the address. | -1 | It depends on the implementation and may not take effects. |
timeout | The calling timeout period. | 3000 (cover 5000) | |
retries | The number of retries after the operation failed. | 0 | The parameter depends on the cluster mode. If the mode is set to failover, this parameter is read. |
callback-class | The callback class. | N/A | This attribute is available for the callback method only. |
callback-ref | The callback class. | N/A | This attribute is available for the callback method only. |