Closed shevawen closed 9 years ago
@JoeCao 您给的例子是个provider,我发的错误是consumer端的
@shevawen java端的consumer 也是一样的,可以发下你consumer的配置,检查是否引入dubbo-rpc-jsonrpc 包,你发的错误应该是没有引入dubbo-rpc-jsonrpc包,所以没有找到扩展的jsonrpc协议实现
consumer.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="ws-demo" />
<!--zookeeper注册中心 -->
<dubbo:registry protocol="zookeeper" address="10.20.26.31:2181" />
<dubbo:reference id="mergeService" interface="org.cimiss.wind_uv_merge.MergeService" timeout="30000" />
<dubbo:reference id="countService" interface="assessment.service.count.CountService" timeout="30000" />
<dubbo:monitor protocol="registry" />
</beans>
pom.xml
<dependency>
<groupId>com.ofpay</groupId>
<artifactId>dubbo-rpc-jsonrpc</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
服务端是否暴露了jsonrpc协议? 另外想提下,既然都是java之间交互为什么要使用jsonrpc呢? 建议走dubbo协议,jsonrpc主要是为了支持跨语言之间的rpc调用。
1、服务端是暴露了的curl测试了的
curl -i -H 'content-type: application/json' -X POST -d '{"jsonrpc": "2.0", "method": "dailyCountGroupByProvince", "params": [ "Nat", true, "2015-01-01","2015-05-01"],"id":1}' 'http://192.168.5.110:8080/assessment-web/assessment.service.count.CountService'
2、同一个service可能同时java和其他语言一起调用,如果不使用多协议提供服务的话,就有java调用jsonrpc情况了
@shevawen 确实是个bug,已修复。
你之前的方式也可以指定dubbo协议
<dubbo:reference id="mergeService" interface="org.cimiss.wind_uv_merge.MergeService" timeout="30000" protocol="dubbo"/>
<dubbo:reference id="countService" interface="assessment.service.count.CountService" timeout="30000" protocol="dubbo"/>
哈哈,赞
@wuwen5 昨天测试通过是因为有其他节点(HTTP协议发布的),今天关掉那个节点,还是有问题的说,多贴一些堆栈信息
15:55:12,888 ERROR RegistryDirectory:372 - Unsupported protocol jsonrpc in notified url: jsonrpc://192.168.5.110:8080/assessment-web/assessment.service.count.CountService?anyhost=true&application=assessment&dubbo=2.5.3&interface=assessment.service.count.CountService&methods=dailyCountGroupByDayFilterByProvince,stationHourlyChangeDetail,provinceHourlyChangeDetail,dailyCountGroupByStationDayFilterByProvince,dailyCountGroupByDayProvince,dailyCountGroupByStationFilterByProvince,provinceESLDetail,blaclkList,dailyCountGroupByProvince,hourlyCount,stationESLDetail&pid=2626&revision=assessment&server=servlet&side=provider&timeout=20000×tamp=1429601961009 from registry 10.20.26.31:2181 to consumer 192.168.5.110, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
java.lang.IllegalStateException: Unsupported protocol jsonrpc in notified url: jsonrpc://192.168.5.110:8080/assessment-web/assessment.service.count.CountService?anyhost=true&application=assessment&dubbo=2.5.3&interface=assessment.service.count.CountService&methods=dailyCountGroupByDayFilterByProvince,stationHourlyChangeDetail,provinceHourlyChangeDetail,dailyCountGroupByStationDayFilterByProvince,dailyCountGroupByDayProvince,dailyCountGroupByStationFilterByProvince,provinceESLDetail,blaclkList,dailyCountGroupByProvince,hourlyCount,stationESLDetail&pid=2626&revision=assessment&server=servlet&side=provider&timeout=20000×tamp=1429601961009 from registry 10.20.26.31:2181 to consumer 192.168.5.110, supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]
at com.alibaba.dubbo.registry.integration.RegistryDirectory.toInvokers(RegistryDirectory.java:372)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.refreshInvoker(RegistryDirectory.java:224)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.notify(RegistryDirectory.java:195)
at com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:449)
at com.alibaba.dubbo.registry.support.FailbackRegistry.doNotify(FailbackRegistry.java:273)
at com.alibaba.dubbo.registry.support.FailbackRegistry.notify(FailbackRegistry.java:259)
at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:170)
at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:189)
at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:133)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:271)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:254)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:63)
at com.alibaba.dubbo.rpc.Protocol$Adpative.refer(Protocol$Adpative.java)
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:392)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1288)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at App.main(App.java:22)
@shevawen 出错的这个消费节点是没有导入dubbo-rpc-jsonrpc包的吧?
服务端暴露多协议建议配置default协议,default协议为dubbo协议
<dubbo:provider> | default | boolean | 可选 | false | 配置关联 | 是否为缺省协议,用于多协议 | 1.0.16以上版本 |
确实导入了。按说jsonrpc应该是在supported protocol: [dubbo, http, injvm, mock, redis, registry, rmi, thrift]这个列表里的。稍晚,我上传一个demo。 本来想,我想看明白 http://blog.csdn.net/quhongwei_zhanqiu/article/details/41577235 之后再问的,但是还没。
做了个demo,发现没问题了 :relaxed: