Commit f4b87b3d by chenweitao

Merge branch 'working' into 'master'

增加httpboot桥接健壮性

See merge request !247
parents 2ab32db9 86535a87
......@@ -36,43 +36,47 @@ public class HttpClientUtils {
static boolean isInit = false;
static {
init();
isInit = true;
}
public static HttpBoot getHttpBoot(){
if (!isInit){
init();
isInit = true;
}
return httpBoot;
}
public static synchronized void init(){
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("hot_search-project");
RegistryConfig registryConfig = new RegistryConfig();
ConsumerConfig consumerConfig = new ConsumerConfig();
String username = null;
String password = null;
if (ProxyConfig.isLocal) {
registryConfig.setAddress(ProxyConfig.localRegistry);
// 设置分组
consumerConfig.setGroup(ProxyConfig.localGroup);
username = ProxyConfig.localUsername;
password = ProxyConfig.localPassword;
} else {
registryConfig.setAddress(ProxyConfig.hangzhouRegistry);
// 设置分组
consumerConfig.setGroup(ProxyConfig.hangzhouGroup);
username = ProxyConfig.hangzhouUsername;
password = ProxyConfig.hangzhouPassword;
}
// 创建 consumer,applicationConfig 非必需参数
CynomysConsumer consumer = CynomysConsumerFactory.create(applicationConfig, registryConfig, consumerConfig, username, password);
try {
LOGGER.info("http-boot桥接 开始...");
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("hot_search-project");
RegistryConfig registryConfig = new RegistryConfig();
ConsumerConfig consumerConfig = new ConsumerConfig();
String username = null;
String password = null;
if (ProxyConfig.isLocal) {
registryConfig.setAddress(ProxyConfig.localRegistry);
// 设置分组
consumerConfig.setGroup(ProxyConfig.localGroup);
username = ProxyConfig.localUsername;
password = ProxyConfig.localPassword;
} else {
registryConfig.setAddress(ProxyConfig.hangzhouRegistry);
// 设置分组
consumerConfig.setGroup(ProxyConfig.hangzhouGroup);
username = ProxyConfig.hangzhouUsername;
password = ProxyConfig.hangzhouPassword;
}
// 创建 consumer,applicationConfig 非必需参数
CynomysConsumer consumer = CynomysConsumerFactory.create(applicationConfig, registryConfig, consumerConfig, username, password);
// 初始化 http-boot 桥接
CynomysFactory.init(consumer);
LOGGER.info("http-boot 桥接 成功");
// 初始化 http-boot 桥接
CynomysFactory.init(consumer);
isInit = true;
}catch (Exception e){
LOGGER.error("http-boot桥接 出错:",e);
}
LOGGER.info("http-boot桥接 成功");
}
public static String sendPost(String url, String jsonParam){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment