weibocom / motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Other
5.9k stars 1.78k forks source link

注解形式创建RegistryConfigBean连接consul失败 #554

Closed FutureElement closed 7 years ago

FutureElement commented 7 years ago

通过xml配置可以连接成功

但是通过注解形式创建RegistryConfigBean却不行 RegistryConfigBean config = new RegistryConfigBean(); config.setBeanName("my_consul"); config.setRegProtocol("consul"); config.setAddress("127.0.0.1:8500"); 错误日志如下: 2017-10-12 10:46:39 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3830f1c0: startup date [Thu Oct 12 10:46:39 CST 2017]; root of context hierarchy 2017-10-12 10:46:39 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [melon-test-provider.xml] 2017-10-12 10:46:40 INFO [info] AllSpiInitialization init. 2017-10-12 10:46:40 INFO [info] AllSpiInitialization init finish. 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'rpcProviderConfig' of type [com.fetech.melon.rpc.provider.config.RpcProviderConfig$$EnhancerBySpringCGLIB$$3fb3b83] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'rpcServiceLoader' of type [com.fetech.melon.rpc.provider.core.RpcServiceLoader] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'rpcClientImpl' of type [com.fetech.melon.rpc.provider.core.RpcClientImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'melonServiceDefaultRegistry' of type [com.weibo.api.motan.config.springsupport.RegistryConfigBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'melonServiceDefaultProtocol' of type [com.weibo.api.motan.config.springsupport.ProtocolConfigBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'melonServiceBaseServiceConfig' of type [com.weibo.api.motan.config.springsupport.BasicServiceConfigBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-10-12 10:46:40 INFO [info] init compress codec 2017-10-12 10:46:40 INFO [info] add method sign:isCo540614bb81f3, methodinfo:MethodInfo [group=melonServiceDefaultGroup, interfaceName=com.fetech.melon.rpc.support.api.RpcClient, methodName=isConnected, paramtersDesc=void, version=1.0] 2017-10-12 10:46:40 INFO [info] add method sign:call208ec30edaf7, methodinfo:MethodInfo [group=melonServiceDefaultGroup, interfaceName=com.fetech.melon.rpc.support.api.RpcClient, methodName=call, paramtersDesc=java.lang.String,java.lang.Object[],java.lang.Class, version=1.0] 2017-10-12 10:46:40 INFO [info] add method sign:callab089b85c7ec, methodinfo:MethodInfo [group=melonServiceDefaultGroup, interfaceName=com.fetech.melon.rpc.support.api.RpcClient, methodName=call, paramtersDesc=java.lang.String,java.lang.String, version=1.0] 2017-10-12 10:46:40 INFO [info] RequestRouter addProvider: url=motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup all_public_method_count=3 2017-10-12 10:46:40 INFO [info] ShutdownHook is initialized 2017-10-12 10:46:40 INFO [info] add resource class com.weibo.api.motan.transport.support.HeartbeatClientEndpointManager$2 to list 2017-10-12 10:46:40 INFO [info] NettyEndpointFactory create share_channel server: url=motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup 2017-10-12 10:46:40 INFO [info] NettyServer ServerChannel start Open: url=motan://10.4.6.155:8002/?group=melonServiceDefaultGroup 2017-10-12 10:46:41 INFO [info] add resource class com.weibo.api.motan.util.StatsUtil$2 to list 2017-10-12 10:46:41 INFO [info] NettyServer ServerChannel finish Open: url=motan://10.4.6.155:8002/?group=melonServiceDefaultGroup 2017-10-12 10:46:41 INFO [info] DefaultRpcExporter node init Success: [DefaultRpcExporter] url=motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup 2017-10-12 10:46:41 INFO [info] DefaultRpcProtocol export Success: url=motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup 2017-10-12 10:46:41 INFO [info] ConsulEcwidClient init finish. client host:127.0.0.1, port:8500 2017-10-12 10:46:41 INFO [info] add resource class com.weibo.api.motan.registry.support.FailbackRegistry$1 to list 2017-10-12 10:46:41 INFO [info] CommandFailbackRegistry init. url: consul://127.0.0.1:8500/com.weibo.api.motan.registry.RegistryService?group=default_rpc 2017-10-12 10:46:41 INFO [info] add resource class com.weibo.api.motan.registry.consul.ConsulRegistry to list 2017-10-12 10:46:41 INFO [info] ConsulRegistry init finish. 2017-10-12 10:46:41 INFO [info] [ConsulRegistry] Url (motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup) will register to Registry [consul://127.0.0.1:8500/default_rpc/com.weibo.api.motan.registry.RegistryService/1.0/service] 2017-10-12 10:46:41 INFO [info] [ConsulRegistry] Url (motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup) will set to available to Registry [consul://127.0.0.1:8500/default_rpc/com.weibo.api.motan.registry.RegistryService/1.0/service] Exception in thread "main" com.weibo.api.motan.exception.MotanFrameworkException: error_message: [ConsulRegistry] false to registery motan://10.4.6.155:8002/com.fetech.melon.rpc.support.api.RpcClient?group=melonServiceDefaultGroup to consul://127.0.0.1:8500/com.weibo.api.motan.registry.RegistryService?group=default_rpc, status: 503, error_code: 20001,r=null at com.weibo.api.motan.registry.support.FailbackRegistry.register(FailbackRegistry.java:93) at com.weibo.api.motan.config.handler.SimpleConfigHandler.register(SimpleConfigHandler.java:112) at com.weibo.api.motan.config.handler.SimpleConfigHandler.export(SimpleConfigHandler.java:80) at com.weibo.api.motan.config.ServiceConfig.doExport(ServiceConfig.java:211) at com.weibo.api.motan.config.ServiceConfig.export(ServiceConfig.java:129) at com.weibo.api.motan.config.springsupport.ServiceConfigBean.onApplicationEvent(ServiceConfigBean.java:95) at com.weibo.api.motan.config.springsupport.ServiceConfigBean.onApplicationEvent(ServiceConfigBean.java:47) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at com.fetech.melon.rpc.testProvider.Start.main(Start.java:13) Caused by: java.lang.UnsupportedOperationException: Command consul registry not support available by urls yet at com.weibo.api.motan.registry.consul.ConsulRegistry.doAvailable(ConsulRegistry.java:85) at com.weibo.api.motan.registry.support.AbstractRegistry.available(AbstractRegistry.java:161) at com.weibo.api.motan.registry.support.AbstractRegistry.register(AbstractRegistry.java:82) at com.weibo.api.motan.registry.support.FailbackRegistry.register(FailbackRegistry.java:90) ... 15 more

rayzhang0603 commented 7 years ago

感谢反馈~ 这个异常的原因是在注册服务时,server的心跳开关(REGISTRY_HEARTBEAT_SWITCHER)已经是开启状态,这时会在注册完一个url后立刻进行available(url)操作,而consul的心跳管理目前不支持针对单个url的心跳available操作。后续的版本会解决这个问题。 目前解决这个问题的方法,可以暂时调整一下打开心跳开关的时序,保证注册完服务后,在开启心跳开关。

FutureElement commented 7 years ago

了解,确实是心跳开关的顺序问题,已解决,谢谢