完善退出机制。
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;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -12,6 +8,7 @@ import org.springframework.boot.CommandLineRunner;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.service.IMsgExchangeService;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AppRunner implements CommandLineRunner {
|
public class AppRunner implements CommandLineRunner {
|
||||||
@@ -21,12 +18,8 @@ public class AppRunner implements CommandLineRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
RedisService redisService;
|
RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
@Value("${msgExchange.waitDateLeftOffset}")
|
IMsgExchangeService msgExchangeService;
|
||||||
private Long waitDateLeftOffset;
|
|
||||||
|
|
||||||
@Value("${msgExchange.intervalSeconds}")
|
|
||||||
private Long intervalSeconds;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
@@ -34,8 +27,7 @@ public class AppRunner implements CommandLineRunner {
|
|||||||
logger.info("app runner start");
|
logger.info("app runner start");
|
||||||
|
|
||||||
//启动消息采集线程
|
//启动消息采集线程
|
||||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
msgExchangeService.start();
|
||||||
scheduledExecutorService.scheduleAtFixedRate(new MsgExchangeRunner(), 0, intervalSeconds , TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
logger.info("app runner end");
|
logger.info("app runner end");
|
||||||
}//end function run
|
}//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")
|
@Service("msgbufferservice")
|
||||||
public class FltrSendBufferService implements IFltrSendBufferService {
|
public class FltrSendBufferServiceImpl implements IFltrSendBufferService {
|
||||||
private static ConcurrentLinkedQueue<SCHD.FLTR> fltrBuffer = new ConcurrentLinkedQueue<SCHD.FLTR>();
|
private static ConcurrentLinkedQueue<SCHD.FLTR> fltrBuffer = new ConcurrentLinkedQueue<SCHD.FLTR>();
|
||||||
|
|
||||||
@Override
|
@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