fix:1.新加邮件日志批次和线程id内容
This commit is contained in:
parent
eccb0480d1
commit
e9c186c9d7
|
@ -48,6 +48,10 @@ public class EmailLogEvent {
|
|||
*/
|
||||
private Date logTime;
|
||||
|
||||
private Long threadId;
|
||||
|
||||
private Integer batchesCounter;
|
||||
|
||||
public EmailLogEvent(){
|
||||
|
||||
}
|
||||
|
@ -60,7 +64,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String logProcess) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String logProcess) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.logProcess = logProcess;
|
||||
this.logTime = new Date();
|
||||
|
@ -73,7 +79,18 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String phdMailLoadPath) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String phdMailLoadPath) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
@ -81,7 +98,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,String recieveTime,String emlPath) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String subject,String recieveTime,String emlPath) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
@ -91,7 +110,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,String recieveTime) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String subject,String recieveTime) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
|
|
@ -201,6 +201,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdHeaderLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get FileNameHeader ");
|
||||
logContent.append(event.getState());
|
||||
|
@ -217,6 +222,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdBodyLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get File ");
|
||||
logContent.append(event.getPhdMailLoadPath());
|
||||
|
@ -234,6 +244,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdEmlLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
|
@ -255,6 +270,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getDeleteLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Delete File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
|
@ -274,6 +294,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getExpungeLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Expunge File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
|
@ -293,6 +318,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getDoneLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Done");
|
||||
logContent.append(LOG_SUFFIX);
|
||||
|
|
|
@ -436,7 +436,7 @@ public class EmailServiceManager {
|
|||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public String getMailSubject(@NotNull Message message) throws MessagingException {
|
||||
public String getMailSubject(@NotNull Message message,Integer batchesCounter) throws MessagingException {
|
||||
String subject = "";
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
try {
|
||||
|
@ -447,7 +447,7 @@ public class EmailServiceManager {
|
|||
status = EmailLogManager.STATUS_ERROR;
|
||||
throw e;
|
||||
}finally {
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER);
|
||||
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER);
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
return subject;
|
||||
|
@ -518,7 +518,7 @@ public class EmailServiceManager {
|
|||
* 新格式为:发件人_主题_年月日_时分秒毫秒_receive_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 当计数大于10000后从0开始,服务重启后也从0开始
|
||||
*/
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException {
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter,Integer batchesCounter) throws MessagingException {
|
||||
String subject = "";
|
||||
File emlFile = null;
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
|
@ -564,7 +564,7 @@ public class EmailServiceManager {
|
|||
log.error(errorMsg);
|
||||
throw new DownloadEmailException(errorMsg);
|
||||
}finally {
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
|
||||
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
|
||||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ public class EmailServiceManager {
|
|||
* @param message
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void removeMail(@NotNull Message message){
|
||||
public void removeMail(@NotNull Message message,Integer batchesCounter){
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
String subject = "";
|
||||
Date receivedDate = null;
|
||||
|
@ -589,10 +589,10 @@ public class EmailServiceManager {
|
|||
log.error("Email deletion failed, the subject of the email is :{}, the reason is :{}.",subject,e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
EmailLogEvent removeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogEvent removeEvent = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),removeEvent);
|
||||
//这里删除和彻底删除一起写入日志,java和C++处理有差异,java是在连接关闭时彻底删除的
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,14 +86,18 @@ public class EmailParsingActuator extends Thread{
|
|||
}
|
||||
}
|
||||
log.info("EmailParsingActuator本次真实执行邮件数量为:{}",messages.length);
|
||||
CountDownLatch taskLatch = new CountDownLatch(messages.length);
|
||||
for(Message message : messages){
|
||||
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
|
||||
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
|
||||
taskLatch,spectrumServiceQuotes,emailCounter);
|
||||
poolExecutor.execute(spectrumParsingActuator);
|
||||
if(messages.length > 0){
|
||||
//本批次邮件号
|
||||
final Integer batchesCounter = spectrumServiceQuotes.getBatchesCounter().getCurrValue();
|
||||
CountDownLatch taskLatch = new CountDownLatch(messages.length);
|
||||
for(Message message : messages){
|
||||
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
|
||||
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
|
||||
taskLatch,spectrumServiceQuotes,emailCounter,batchesCounter);
|
||||
poolExecutor.execute(spectrumParsingActuator);
|
||||
}
|
||||
taskLatch.await();
|
||||
}
|
||||
taskLatch.await();
|
||||
}
|
||||
}catch (InterruptedException | MessagingException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -80,15 +81,19 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected List<String> spectrumFileLabels = Lists.newArrayList();
|
||||
|
||||
protected Integer batchesCounter;
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
public void init(String mailContent,String emlFileName,SpectrumServiceQuotes spectrumServiceQuotes,StringBuilder returnFileName,Integer spectrumSource) throws Exception{
|
||||
public void init(String mailContent, String emlFileName, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
StringBuilder returnFileName, Integer spectrumSource, Integer batchesCounter) throws Exception{
|
||||
this.mailContent = mailContent;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.returnFileName = returnFileName;
|
||||
this.spectrumSource = spectrumSource;
|
||||
this.emlFileName = emlFileName;
|
||||
this.batchesCounter = batchesCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +114,9 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File spectrumFile,
|
||||
String sourceFilePath,DataType currDataType,
|
||||
String mailContent,String emlFileName,Integer spectrumSource,StringBuilder returnFileName){
|
||||
String mailContent,String emlFileName,
|
||||
Integer spectrumSource,StringBuilder returnFileName,
|
||||
Integer batchesCounter){
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.spectrumFile = spectrumFile;
|
||||
this.sourceFilePath = sourceFilePath;
|
||||
|
@ -118,6 +125,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
this.emlFileName = emlFileName;
|
||||
this.spectrumSource = spectrumSource;
|
||||
this.returnFileName = returnFileName;
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.setChina();
|
||||
}
|
||||
|
||||
|
@ -242,7 +250,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
e.printStackTrace();
|
||||
}finally {
|
||||
if(SpectrumSource.FORM_EMAIL_SERVICE.getSourceType().equals(spectrumSource)){
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDBODY,
|
||||
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDBODY,
|
||||
Objects.isNull(this.spectrumFile)?" ":this.spectrumFile.getAbsolutePath());
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
AbstractSpectrumHandler spectrumHandler = new HealthStatusSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 批次计数器
|
||||
*/
|
||||
@Component
|
||||
public class BatchesCounter {
|
||||
|
||||
private Object lock = new Object();
|
||||
|
||||
private AtomicInteger batchesCounter = new AtomicInteger();
|
||||
|
||||
public int getCurrValue(){
|
||||
synchronized (lock){
|
||||
return batchesCounter.getAndIncrement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new QcphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new MetSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
AbstractSpectrumHandler spectrumHandler = new AlertSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new GasbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new DetbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
* 邮件计数器
|
||||
*/
|
||||
private EmailCounter emailCounter;
|
||||
|
||||
private Integer batchesCounter;
|
||||
/**
|
||||
* 一天秒数
|
||||
*/
|
||||
|
@ -65,13 +67,14 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
|
||||
public void init(Message message, EmailProperties emailProperties,EmailServiceManager emailServiceManager,
|
||||
CountDownLatch taskLatch, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter){
|
||||
EmailCounter emailCounter,Integer batchesCounter){
|
||||
this.message = message;
|
||||
this.emailProperties = emailProperties;
|
||||
this.emailServiceManager = emailServiceManager;
|
||||
this.taskLatch = taskLatch;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.emailCounter = emailCounter;
|
||||
this.batchesCounter = batchesCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +82,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
String subject = null;
|
||||
try {
|
||||
//获取邮件主题
|
||||
subject = emailServiceManager.getMailSubject(message);
|
||||
subject = emailServiceManager.getMailSubject(message,this.batchesCounter);
|
||||
|
||||
//解析之前先把邮件唯一信息存储到redis
|
||||
String messageId = ((MimeMessage) message).getMessageID();
|
||||
|
@ -90,7 +93,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
SpectrumLogManager.mailSpectrumLogManager.offer(Thread.currentThread().getId(),null);
|
||||
|
||||
//所有邮件都需以.eml格式存储到eml文件夹中
|
||||
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue());
|
||||
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue(),this.batchesCounter);
|
||||
//保存邮件日志到PG数据库
|
||||
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
|
||||
|
||||
|
@ -104,7 +107,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
// 如果邮件内容校验成功 将文件保存到eml目录 并删除邮件对象
|
||||
if(checkMailContent(mailContent,subject)){
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType());
|
||||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType(),batchesCounter);
|
||||
final boolean matchResult = spectrumHandler.saveEmailToLocal();
|
||||
if(matchResult){
|
||||
//开始解析
|
||||
|
@ -112,7 +115,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}else{
|
||||
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
|
||||
}
|
||||
emailServiceManager.removeMail(message);
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
}else {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
|
@ -125,12 +128,12 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
} catch (Exception e) {
|
||||
// 如果不是下载导致的失败,则删除下载的邮件对象
|
||||
if(!(e instanceof DownloadEmailException)){
|
||||
emailServiceManager.removeMail(message);
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(this.batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
|
||||
|
||||
EmailLogManager.getInstance().writeLog(Thread.currentThread().getId());
|
||||
|
|
|
@ -90,4 +90,6 @@ public class SpectrumServiceQuotes {
|
|||
*/
|
||||
private final Object originalLibraryLock = new Object();
|
||||
|
||||
private final BatchesCounter batchesCounter;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user