spring-boot motan 整合

2016-09-16  本文已影响0人  _流浪的猫_

现在在项目中已经应用了spring-boot,其有很多starter方便使用,因此打算写一个motan的starter,用起来更像spring-boot的风格。另一个是官方的例子还不是很完善,后续可能会修改吧。

// 非local配置时,才去配置
if (!registryConfig.getRegProtocol().toLowerCase().equals("local")) {
 MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
  }

目前大概实现这些,还有一些属性不全,Motan官方的配置文档中有些属性已经不能使用,估计是对之前的版本兼容

具体代码参考github


使用的方法参照demo

主要是:

    <dependency>
      <groupId>com.github.chenxing2.motan</groupId>
      <artifactId>spring-boot-starter-motan</artifactId>
      <version>0.1</version>
    </dependency>
# Motan Aonnotation config
motan.annotation.package=com.github.chenxing2.demo.server
# Motan Registry config
#
# 不使用注册中心
motan.registry.regProtocol=local
#
# 使用注册中心,zookeeper
#motan.registry.regProtocol=zookeeper
#motan.registry.address=127.0.0.1:2181
#motan.registry.connectTimeout=2000
#
# Motan Protocol config
# Motan BasicService config
motan.basicservice.application=demo
motan.basicservice.exportPort=8888
motan.basicservice.accessLog=false
motan.basicservice.shareChannel=true
# Motan Aonnotation config
motan.annotation.package=com.github.chenxing2.demo.client
# Motan Registry config
#
# 不使用注册中心,这里配置为 direct,而不是local
motan.registry.regProtocol=direct
motan.registry.address=localhost:8888
#
# 使用注册中心,zookeeper
#motan.registry.regProtocol=zookeeper
#motan.registry.address=127.0.0.1:2181
#motan.registry.connectTimeout=2000
#
# Motan Protocol config
# Motan BasicService config
motan.basicreferer.application=demo
motan.basicreferer.accessLog=false
motan.basicreferer.retries=3
motan.basicreferer.throwException=true
上一篇 下一篇

猜你喜欢

热点阅读