master
hbr 2024-06-11 15:30:08 +08:00
commit dd87fe12b8
5 changed files with 5 additions and 11 deletions

View File

@ -28,6 +28,7 @@ public class ManyJob {
@Autowired @Autowired
private EntinfoServiceImpl entinfoService; private EntinfoServiceImpl entinfoService;
// @Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次 // @Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次
public void manyJob(){ public void manyJob(){
redisService.deleteObject("entinfo"); redisService.deleteObject("entinfo");

View File

@ -160,6 +160,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
@Autowired @Autowired
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;
/** /**
* http URL * http URL
* @param business * @param business
@ -196,12 +197,12 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
new InputStreamReader(httpConn.getInputStream())); new InputStreamReader(httpConn.getInputStream()));
String resultData = br.readLine(); String resultData = br.readLine();
System.out.println("从服务端返回结果: " + resultData); System.out.println("从服务端返回结果: " + resultData);
// 7.关闭HttpURLConnection连接 // 7.关闭HttpURLConnection连接
httpConn.disconnect(); httpConn.disconnect();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
Entinfo build = Entinfo.builder() Entinfo build = Entinfo.builder()
.entCode("test_" + business.getId()) .entCode("test_" + business.getId())
.ip("192.168.120.128") .ip("192.168.120.128")

View File

@ -73,7 +73,6 @@ public class GenController extends BaseController {
List<GenTable> list = genTableService.selectDbTableList(genTable); List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* *
*/ */

View File

@ -67,13 +67,6 @@ public class ManyDataSource {
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")}) @RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
public void smsConfig(String msg, Message message, Channel channel){ public void smsConfig(String msg, Message message, Channel channel){
//获取消息的ID //获取消息的ID
// new Thread(() -> {
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }).start();
String messageId = message.getMessageProperties().getMessageId(); String messageId = message.getMessageProperties().getMessageId();
try { try {
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费 //添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
@ -103,7 +96,6 @@ public class ManyDataSource {
private void druidData(String msg) { private void druidData(String msg) {
Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class); Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class);
log.info("消息为:{}",entinfo1); log.info("消息为:{}",entinfo1);
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class); DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class); DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort()); DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort());
@ -123,7 +115,6 @@ public class ManyDataSource {
// List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll(); // List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll();
// databaseNameList.a(entinfos) // databaseNameList.a(entinfos)
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1); List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
entinfo.forEach(string -> { entinfo.forEach(string -> {
Entinfo entInfo = JSON.parseObject(string, Entinfo.class); Entinfo entInfo = JSON.parseObject(string, Entinfo.class);
databaseNameList.add(entInfo); databaseNameList.add(entInfo);

View File

@ -27,6 +27,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
*/ */
private Map<Object, Object> defineTargetDataSources; private Map<Object, Object> defineTargetDataSources;
/** /**
* 线使 * 线使
*/ */
@ -35,6 +36,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
return DynamicDataSourceHolder.getDynamicDataSourceKey(); return DynamicDataSourceHolder.getDynamicDataSourceKey();
} }
/** /**
* *
* @param key * @param key