dubbo java 发布订阅(非spring配置)
发布 service
ApplicationConfig config=new ApplicationConfig("springboot-dubbo-productor"); RegistryConfig reg=new RegistryConfig("localhost:2181"); reg.setProtocol("zookeeper"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(20880); ServiceConfig<CoreService> service=new ServiceConfig<CoreService>(); service.setApplication(config); service.setRegistry(reg); service.setProtocol(protocol); service.setInterface(CoreService.class); service.setRef(coreService); service.setVersion("1.0"); service.export();
订阅service
ApplicationConfig config = new ApplicationConfig("springboot-dubbo-consumer"); RegistryConfig reg = new RegistryConfig("localhost:2181"); reg.setProtocol("zookeeper"); ReferenceConfig<CoreService> refrence=new ReferenceConfig<CoreService>(); refrence.setApplication(config); refrence.setRegistry(reg); refrence.setInterface(CoreService.class); refrence.setVersion("1.0"); CoreService coreService = refrence.get();
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。
个人主页:http://knight-black-bob.iteye.com/
谢谢您的赞助,我会做的更好!