SOFABoot 环境发布订阅说明

优质
小牛编辑
116浏览
2023-12-01

这部分介绍在 SOFABoot 环境下,完整的 SOFARPC 服务发布与引用说明

发布服务

 <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>
属性名称默认值备注
idIDbean名
class
ref服务接口实现类
interface服务接口(唯一标识元素)不管是普通调用和返回调用,这里都设置实际的接口类
unique-id服务标签(唯一标识元素)
filter过滤器配置别名多个用逗号隔开
registry服务端注册中心逗号分隔
timeout服务端执行超时时间
serialize-type序列化协议hessian2,protobuf
thread-pool-ref 服务端当前接口使用的线程池
weight服务静态权重
warm-up-weight服务预热权重
warm-up-time服务预热时间单位毫秒

引用服务

<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>
属性名称默认值备注
idID自动生成
jvm-first是否优先本地true
interface服务接口(唯一标识元素)不管是普通调用和返回调用,这里都设置实际的接口类
unique-id服务标签(唯一标识元素)
type调用方式synccallback,sync,future,oneway
filter过滤器配置别名List
registry服务端注册中心List
method方法级配置说明同上
serialize-type序列化协议hessian2
target-url直连地址直连后register
generic-interface泛化接口
connect.timeout建立连接超时时间3000(cover 5000)
connect.num连接数1
idle.timeout空闲超时时间
idle.timeout.read读空闲超时时间
loadBalancer负载均衡算法random
lazy是否延迟建立长连接false
address-wait-time等待地址获取时间-1取决于实现,可能不生效。
timeout调用超时时间3000(cover 5000)
retries失败后重试次数0跟集群模式有关,failover读取此参数。
callback-classcallback 回调类callback 才可用
callback-refcallback 回调类callback 才可用