提交 a0dc2381 编写于 作者: fengmin's avatar fengmin

mq消息订阅实现3

上级 cd359f06
......@@ -7,7 +7,6 @@ import cn.ibizlab.core.analysis.service.IDAMetricService;
import cn.ibizlab.core.analysis.service.impl.DABuildServiceImpl;
import cn.ibizlab.core.extensions.domain.BaseRequest;
import cn.ibizlab.core.extensions.domain.EngineMQMsg;
import cn.ibizlab.core.extensions.util.DefaultMQProducerService;
import cn.ibizlab.core.extensions.util.MsgProducerService;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.core.lite.extensions.model.DataModel;
......@@ -15,7 +14,6 @@ import cn.ibizlab.core.lite.extensions.service.LiteDataCallback;
import cn.ibizlab.core.lite.extensions.service.LiteDataService;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.core.rule.domain.ExecLog;
import cn.ibizlab.core.rule.domain.RuleEngine;
import cn.ibizlab.core.rule.domain.RuleItem;
import cn.ibizlab.core.rule.service.IExecLogService;
import cn.ibizlab.core.rule.service.IRuleItemService;
......@@ -31,7 +29,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
......@@ -268,8 +265,9 @@ public class DABuildExService extends DABuildServiceImpl {
rulePaths.add(path);
ruleIds.add(ruleItem.getRuleId());
}
if((!StringUtils.isEmpty(ruleItem.getCond()))&&ruleItem.getCond().startsWith("["))
fillpropertys.addAll(JSON.toJavaObject(JSON.parseArray(ruleItem.getCond()), List.class));
if((!StringUtils.isEmpty(ruleItem.getCond()))&&ruleItem.getCond().startsWith("[")) {
fillpropertys.addAll(JSON.toJavaObject(JSON.parseArray(ruleItem.getCond()), LinkedHashSet.class));
}
});
Assert.notEmpty(ruleIds,"构建数据失败:无有效规则");
......
......@@ -3,8 +3,6 @@ package cn.ibizlab.core.util.config;
import cn.ibizlab.core.extensions.util.GeneralConsumeMsgListenerProcessor;
import cn.ibizlab.core.rule.domain.RuleEngine;
import cn.ibizlab.core.rule.mapper.RuleEngineExtendMapper;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import lombok.extern.slf4j.Slf4j;
......@@ -18,16 +16,10 @@ import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.Query;
import java.lang.management.ManagementFactory;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@Component
......@@ -101,59 +93,4 @@ public class RocktcermqCustmerRunner implements ApplicationRunner {
return flat;
}
/**
* 外部容器启动服务时,自动注册服务到nacos
*/
@Component
@Slf4j
public static class NacosRegisterConfig implements ApplicationRunner {
@Autowired(required = false)
private NacosAutoServiceRegistration registration;
@Value("${server.port:8080}")
Integer port;
@Override
public void run(ApplicationArguments args) {
log.info("正在尝试将应用程序注册到nacos");
if (registration != null && port != null) {
try {
String containerPort = getContainerPort();
if(!StringUtils.isEmpty(containerPort)){
registration.setPort(new Integer(containerPort));
}
else{
registration.setPort(port);
log.info("无法获取外部容器端口,将使用程序默认端口{}",port);
}
registration.start();
} catch (Exception e) {
throw new BadRequestAlertException("应用程序注册到nacos失败,"+e,"","");
}
log.info("已将应用程序成功注册到nacos");
}
else{
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略。");
}
}
/**
* 获取外部容器端口
*/
public String getContainerPort(){
String port = null;
try {
MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"), Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
if(!ObjectUtils.isEmpty(objectNames)){
port = objectNames.iterator().next().getKeyProperty("port");
}
}
catch (Exception e) {
log.error("获取外部容器端口失败!"+e);
}
return port;
}
}
}
spring:
profiles:
include: sys ,nacos, api-prod,dev
include: sys ,nacos, api-prod
application:
name: ibzdst-api
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册