motan配置详解

本文详细介绍了Motan框架的协议配置,包括服务协议的属性如name、serialization、payload等,以及注册中心配置的属性如name、regProtocol、address等。此外,还涵盖了服务端和客户端的配置细节,如服务暴露、服务引用的相关参数。这些配置对于理解和使用Motan框架进行微服务通信至关重要。
摘要由CSDN通过智能技术生成

由于github时不时的无法访问。所以把官网的配置黏贴过来。

协议配置列表

<motan:protocol/>

Property nameTypeDefaultComment
nameString服务协议名
serializationStringhessian2序列化方式
payloadint最大请求数据长度
bufferint缓存区大小
heartbeatint心跳间隔
transporterString网络传输方式
threadsint线程池大小
iothreadsintavailableProcessors+1IO线程池大小
requestTimeoutint200请求超时
minClientConnectionint2client最小连接数
maxClientConnectionint10client最大连接数
minWorkerThreadint20最小工作pool线程数
maxWorkerThreadint200最大工作pool线程数
maxContentLengthint10M请求响应包的最大长度限制
maxServerConnectionint100000server支持的最大连接数
poolLifobooleantrue连接池管理方式,是否lifo
lazyInitbooleanfalse是否延迟init
endpointFactorybooleanmotanendpoint factory
clusterStringdefault采用哪种cluster的实现
loadbalanceStringactiveWeight负载均衡策略
haStrategyStringfailover高可用策略
workerQueueSizeString0Server工作队列大小
acceptConnectionsint0Server可接受连接数
proxyStringjdkproxy type, like jdk or javassist
filterStringfilter, 多个filter用","分割,blank String 表示采用默认的filter配置
retriesint0调用失败时重试次数
asyncbooleanfalseif the request is called async, a taskFuture result will be sent back
queueSizeInt线程池队列大小
acceptsInt最大接收连接数
dispatcherString信息线程模型派发方式
serverString服务器端实现
clientString客户端端实现
defaultboolean是否缺省的配置
switcherServiceStringlocalSwitcherService
heartbeatFactoryStringmotan

注册中心配置列表

<motan:registry/>

Property nameTypeDefaultComment
nameString注册配置名称
regProtocolString注册协议
addressString注册中心地址
portint0注册中心缺省端口
connectTimeoutint1000注册中心连接超时时间(毫秒)
requestTimeoutint200注册中心请求超时时间(毫秒)
registrySessionTimeoutint60s注册中心会话超时时间(毫秒)
registryRetryPeriodint30s失败后重试的时间间隔
checkbooleantrue启动时检查失败后是否仍然启动
registerbooleantrue在该注册中心上服务是否暴露
subscribebooleantrue在该注册中心上服务是否引用
defaultboolean是否缺省的配置

服务端配置列表

<motan:service/>

<motan:basicService/>

protocol、basic service、extConfig、service中定义相同属性时,优先级为service > extConfig > basic service > protocol

Property nameTypeDefaultComment
exportString服务暴露的方式,包含协议及端口号,多个协议端口用"," 分隔
basicService基本service配置
interfaceClass服务接口名
refString接口实现的类
classString实现service的类名
hostString如果有多个ip,但只想暴露指定的某个ip,设置该参数
pathString服务路径
serializationStringhessian2序列化方式
extConfigString扩展配置
proxyString代理类型
groupStringdefault_rpc服务分组
versionString1.0版本
throwExceptionStringtrue抛出异常
requestTimeoutString200(目前未用)请求超时时间(毫秒)
connectTimeoutString1000(目前未用)连接超时时间(毫秒)
retriesint0(目前未用)重试次数
filterString过滤器配置
listenerString监听器配置
connectionsint连接数限制,0表示共享连接,否则为该服务独享连接数;默认共享
applicationStringmotan应用信息
moduleStringmotan模块信息
shareChannelbooleanfalse是否共享channel
timeoutint方法调用超时时间
activesint0最大请求数,0为不做并发限制
asyncbooleanfalse方法是否异步
mockStringfalse设为true,表示使用缺省Mock类名,即:接口名+Mock 后缀,服务接口调用失败Mock实现类
checkbooleantrue检查服务提供者是否存在
registryString注册中心的id 列表,多个用“,”分隔,如果为空,则使用所有的配置中心
registerbooleantrue在该注册中心上服务是否暴露
subscribebooleantrue在该注册中心上服务是否引用
accessLogStringfalse设为true,将向logger 中输出访问日志
usegzbooleanfalse是否开启gzip压缩.只有compressMotan的codec才能支持
mingzSizeint1000开启gzip压缩的阈值.usegz开关开启,且传输数据大于此阈值时,才会进行gzip压缩。只有compressMotan的codec才能支持
codecStringmotan协议编码

client配置列表

<motan:referer/>

<motan:basicReferer/>

protocol、basic referer、extConfig、referer中定义相同属性时,优先级为referer > extConfig > basic referer > protocol

Property nameTypeDefaultComment
idString服务引用 BeanId
protocolStringmotan使用的协议
interfaceClass服务接口名
clientString客户端类型
directUrlString点对点直连服务提供地址
basicRefererString基本 referer 配置
extConfigString扩展配置
proxyString代理类型
groupStringdefault_rpc服务分组
versionString1.0版本
throwExceptionStringtrue抛出异常
requestTimeoutString200请求超时时间(毫秒)
connectTimeoutString1000连接超时时间(毫秒)
retriesint0重试次数
filterString过滤器配置
listenerString监听器配置
connectionsint连接数限制,0表示共享连接,否则为该服务独享连接数;默认共享
applicationStringmotan应用信息
moduleStringmotan模块信息
shareChannelbooleanfalse是否共享channel
timeoutint(目前未用)方法调用超时时间
activesint0最大请求数,0为不做并发限制
asyncbooleanfalse方法是否异步
mockStringfalse设为true,表示使用缺省Mock类名,即:接口名+Mock 后缀,服务接口调用失败Mock实现类
checkbooleantrue检查服务提供者是否存在
registryString注册中心的id 列表,多个用“,”分隔,如果为空,则使用所有的配置中心
registerbooleantrue在该注册中心上服务是否暴露
subscribebooleantrue在该注册中心上服务是否引用
accessLogStringfalse设为true,将向logger 中输出访问日志
usegzbooleanfalse是否开启gzip压缩.只有compressMotan的codec才能支持
mingzSizeint1000开启gzip压缩的阈值.usegz开关开启,且传输数据大于此阈值时,才会进行gzip压缩。只有compressMotan的codec才能支持
codecStringmotan协议编码

<motan:method/>
需要定义在motan:referer内,用于控制某个函数的行为

Property nameTypeDefaultComment
nameString函数名
argumentTypesString参数类型(逗号分隔), 无参数用void. 如果方法无重载,则可不写
requestTimeoutint200请求超时时间(毫秒)
connectTimeoutint1000连接超时时间(毫秒)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乌拉乌拉liang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值