Closed back-zhao closed 5 years ago
这个异常应该是反射调用server端方法时,参数类型不匹配。yar协议只支持简单的数据类型,特别是list和map的泛型最好使用Object,方便与弱类型语言交互。
可以参考demo模块中com.weibo.motan.demo.service.YarService
的方法声明
谢谢回复,入参出参都为简单类型么,我试了下MSGPACK的方式调用参数为字符串、返回值为对象的接口有异常。JSON方式正常调用。异常如下:Exception in thread "main" java.lang.IllegalArgumentException: Cannot deserialize instance of com.cloudwise.model.UserModel
out of START_ARRAY token
at [Source: UNKNOWN; line: -1, column: -1]
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3750)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3668)
at com.weibo.yar.YarResponse.getValue(YarResponse.java:40)
at com.weibo.yar.yarclient.AbstractYarClient.buildResponse(AbstractYarClient.java:61)
at com.weibo.yar.yarclient.AbstractYarClient.call(AbstractYarClient.java:42)
at com.weibo.yar.yarclient.AbstractYarClient.call(AbstractYarClient.java:36)
at com.cloudwise.client.YarClient.main(YarClient.java:20)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.cloudwise.model.UserModel
out of START_ARRAY token
at [Source: UNKNOWN; line: -1, column: -1]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1342)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1138)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1092)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1461)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:161)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3745)
... 6 more
旧版本的msgpack序列化时应该需要注册序列化模板,建议跨语言使用时直接使用json字符串。
也可以关注一下Breeze序列化,可以支持java对象跨语言序列化,近期会发布正式版本并集成到motan中,可以配合motan2协议支持多语言交互
谢谢回复。还有motan Manager中的手动切换功能,比如Group A->GroupB。流量切换配置后发现正在进行的对A的请求正常访问A,但是新的请求会有异常出现。异常如下: com.weibo.api.motan.exception.MotanServiceException: error_message: ActiveWeightLoadBalance No available referers for call : referers_size= 0 requestId=1640652518972194817 interface=com.cloudwise.service.UserService method=showUser(void), status: 503, error_code: 10001,r=null at com.weibo.api.motan.cluster.loadbalance.AbstractLoadBalance.selectToHolder(AbstractLoadBalance.java:73) at com.weibo.api.motan.cluster.ha.FailoverHaStrategy.selectReferers(FailoverHaStrategy.java:90) at com.weibo.api.motan.cluster.ha.FailoverHaStrategy.call(FailoverHaStrategy.java:53) at com.weibo.api.motan.cluster.support.ClusterSpi.call(ClusterSpi.java:73) at com.weibo.api.motan.proxy.AbstractRefererHandler.invokeRequest(AbstractRefererHandler.java:77) at com.weibo.api.motan.proxy.RefererInvocationHandler.invoke(RefererInvocationHandler.java:72) at com.sun.proxy.$Proxy12.showUser(Unknown Source) at com.cloudwise.service.impl.TestHandler.handler(TestHandler.java:15) at com.cloudwise.client.SpringAnnoClient.main(SpringAnnoClient.java:18) Exception in thread "main" com.weibo.api.motan.exception.MotanServiceException: error_message: ActiveWeightLoadBalance No available referers for call : referers_size= 0 requestId=1640652518972194817 interface=com.cloudwise.service.UserService method=showUser(void), status: 503, error_code: 10001,r=null at com.weibo.api.motan.cluster.loadbalance.AbstractLoadBalance.selectToHolder(AbstractLoadBalance.java:73) at com.weibo.api.motan.cluster.ha.FailoverHaStrategy.selectReferers(FailoverHaStrategy.java:90) at com.weibo.api.motan.cluster.ha.FailoverHaStrategy.call(FailoverHaStrategy.java:53) at com.weibo.api.motan.cluster.support.ClusterSpi.call(ClusterSpi.java:73) at com.weibo.api.motan.proxy.AbstractRefererHandler.invokeRequest(AbstractRefererHandler.java:77) at com.weibo.api.motan.proxy.RefererInvocationHandler.invoke(RefererInvocationHandler.java:72) at com.sun.proxy.$Proxy12.showUser(Unknown Source) at com.cloudwise.service.impl.TestHandler.handler(TestHandler.java:15) at com.cloudwise.client.SpringAnnoClient.main(SpringAnnoClient.java:18)
看异常提示referers_size= 0
说明新发现的分组中没有获取到可用节点信息,可用在info日志中查找关键字ClusterSupport config change notify
确认是否成功订阅到了groupB的节点
配置前都是可以单独正常访问的,手动配置流量切换后,新请求如此。有空时我看下配置后zk上的信息情况,再和您沟通。谢谢
java client设置MSGPACK和JSON 都无法正常调用。异常如下: Exception in thread "main" com.weibo.yar.YarException: argument type mismatch at com.weibo.yar.yarclient.AbstractYarClient.buildResponse(AbstractYarClient.java:59) at com.weibo.yar.yarclient.AbstractYarClient.call(AbstractYarClient.java:42) at com.weibo.yar.yarclient.AbstractYarClient.call(AbstractYarClient.java:36) at com.cloudwise.client.YarClient.main(YarClient.java:23)