1.完善采集线程的未知异常捕获。2.设置采集线程名字 3.去除多余的日志打印
This commit is contained in:
@@ -2,11 +2,13 @@ package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.gzzn.omms.msgexchangeapi.runner.MsgExchangeRunner;
|
||||
|
||||
@Service
|
||||
@@ -25,7 +27,10 @@ public class MsgExchangeServiceImpl implements IMsgExchangeService {
|
||||
{
|
||||
//启动消息采集线程
|
||||
if (null == scheduledExecutorService) {
|
||||
scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
ThreadFactory namedThreadFactory =
|
||||
new ThreadFactoryBuilder().setNameFormat("msgexchange-%d").build(); //为线程池添加名字
|
||||
|
||||
scheduledExecutorService = Executors.newScheduledThreadPool(1, namedThreadFactory);
|
||||
scheduledExecutorService.scheduleAtFixedRate(new MsgExchangeRunner(), 0, intervalSeconds , TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user