提交 cd14f39d 编写于 作者: hebao@lab.ibiz5.com's avatar hebao@lab.ibiz5.com

Revert "使用消息队列构建"

上级 1b36ba7e
...@@ -34,6 +34,7 @@ import org.mybatis.spring.batch.MyBatisCursorItemReader; ...@@ -34,6 +34,7 @@ import org.mybatis.spring.batch.MyBatisCursorItemReader;
import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
...@@ -73,15 +74,15 @@ public class RuleEngineExService extends RuleEngineServiceImpl { ...@@ -73,15 +74,15 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
@Autowired @Autowired
private IMetaModelService metaModelService; private IMetaModelService metaModelService;
@Autowired
private SqlSessionFactory sqlSessionFactory;
@Autowired @Autowired
private DstDataSourceExService dstDataSourceService; private DstDataSourceExService dstDataSourceService;
@Autowired @Autowired
DefaultMQProducer defaultMQProducer; DefaultMQProducer defaultMQProducer;
@Autowired
@Lazy
private SqlSessionFactory sqlSessionFactory;
@Value("${rocketmq.producer.ruleEngineTopic: DSTMSG}") @Value("${rocketmq.producer.ruleEngineTopic: DSTMSG}")
private String ruleEngineTopic; private String ruleEngineTopic;
...@@ -115,11 +116,11 @@ public class RuleEngineExService extends RuleEngineServiceImpl { ...@@ -115,11 +116,11 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
String sql=entityModel.getSqlSegment("CORE"); String sql=entityModel.getSqlSegment("CORE");
MyBatisCursorItemReader myMyBatisCursorItemReader =new MyBatisCursorItemReader(); MyBatisCursorItemReader myMyBatisCursorItemReader =new MyBatisCursorItemReader();
try{ try{
List<EntityObj> kEntityObjs=dbEntityService.selectCore(entityModel, filter); // List<EntityObj> kEntityObjs=dbEntityService.selectCore(entityModel, filter);
if(kEntityObjs != null){ // if(kEntityObjs != null){
this.sendToMQ(et.getEngineId(), kEntityObjs); // this.sendToMQ(et.getEngineId(), kEntityObjs);
return et; // return et;
} // }
myMyBatisCursorItemReader.setSqlSessionFactory(sqlSessionFactory); myMyBatisCursorItemReader.setSqlSessionFactory(sqlSessionFactory);
myMyBatisCursorItemReader.setQueryId("cn.ibizlab.core.extensions.mapper.DbEntityMapper.search"); myMyBatisCursorItemReader.setQueryId("cn.ibizlab.core.extensions.mapper.DbEntityMapper.search");
...@@ -145,6 +146,7 @@ public class RuleEngineExService extends RuleEngineServiceImpl { ...@@ -145,6 +146,7 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
batch.add(rowdata); batch.add(rowdata);
if(batch.size() > 500){ if(batch.size() > 500){
this.sendToMQ(et.getEngineId(), batch); this.sendToMQ(et.getEngineId(), batch);
batch.clear();
} }
} }
if(batch.size() > 0){ if(batch.size() > 0){
...@@ -153,11 +155,11 @@ public class RuleEngineExService extends RuleEngineServiceImpl { ...@@ -153,11 +155,11 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { // try {
myMyBatisCursorItemReader.close();// 关闭游标 // myMyBatisCursorItemReader.close();// 关闭游标
} catch (Exception ex) { // } catch (Exception ex) {
log.error(ex.getMessage()); // log.error(ex.getMessage());
} // }
DynamicDataSourceContextHolder.poll(); DynamicDataSourceContextHolder.poll();
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册