完善退出机制。
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata.manager;
|
||||
|
||||
/**
|
||||
* 机位登机桥,关系管理
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
public class OrmsStandAirbridge {
|
||||
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.gzzn.omms.msgexchangeapi.runner;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -12,6 +8,7 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.IMsgExchangeService;
|
||||
|
||||
@Component
|
||||
public class AppRunner implements CommandLineRunner {
|
||||
@@ -21,12 +18,8 @@ public class AppRunner implements CommandLineRunner {
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
|
||||
@Value("${msgExchange.waitDateLeftOffset}")
|
||||
private Long waitDateLeftOffset;
|
||||
|
||||
@Value("${msgExchange.intervalSeconds}")
|
||||
private Long intervalSeconds;
|
||||
@Autowired
|
||||
IMsgExchangeService msgExchangeService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
@@ -34,9 +27,8 @@ public class AppRunner implements CommandLineRunner {
|
||||
logger.info("app runner start");
|
||||
|
||||
//启动消息采集线程
|
||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
scheduledExecutorService.scheduleAtFixedRate(new MsgExchangeRunner(), 0, intervalSeconds , TimeUnit.SECONDS);
|
||||
|
||||
msgExchangeService.start();
|
||||
|
||||
logger.info("app runner end");
|
||||
}//end function run
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 应用退出服务
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationExitService {
|
||||
|
||||
@Autowired
|
||||
IMsgExchangeService msgExchangeService;
|
||||
|
||||
@PreDestroy
|
||||
public void destory() {
|
||||
msgExchangeService.stop();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD.FLTR;
|
||||
*
|
||||
*/
|
||||
@Service("msgbufferservice")
|
||||
public class FltrSendBufferService implements IFltrSendBufferService {
|
||||
public class FltrSendBufferServiceImpl implements IFltrSendBufferService {
|
||||
private static ConcurrentLinkedQueue<SCHD.FLTR> fltrBuffer = new ConcurrentLinkedQueue<SCHD.FLTR>();
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
public interface IMsgExchangeService {
|
||||
/**
|
||||
* 启动采集线程
|
||||
*/
|
||||
public void start();
|
||||
|
||||
/**
|
||||
* 停止采集线程
|
||||
*/
|
||||
public void stop();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.runner.MsgExchangeRunner;
|
||||
|
||||
@Service
|
||||
public class MsgExchangeServiceImpl implements IMsgExchangeService {
|
||||
|
||||
@Value("${msgExchange.intervalSeconds}")
|
||||
private Long intervalSeconds;
|
||||
|
||||
|
||||
private ScheduledExecutorService scheduledExecutorService = null;
|
||||
|
||||
/**
|
||||
* 启动采集线程
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
//启动消息采集线程
|
||||
if (null == scheduledExecutorService) {
|
||||
scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
scheduledExecutorService.scheduleAtFixedRate(new MsgExchangeRunner(), 0, intervalSeconds , TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止采集线程
|
||||
*/
|
||||
public void stop()
|
||||
{
|
||||
scheduledExecutorService.shutdown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user