自动处理模块自动处理程序管理类增加邮箱更新数据相关逻辑代码

邮件属性实体类增加标识resetFlag,标识邮件基础信息是否需要进行更新
邮件解析执行代码增加更新邮箱基础信息方法
邮件解析执行代码增加逻辑判断当前线程是否处于中止状态,如果处于中止状态结束当前方法
自动处理模块错误日志写入代码中动态错误增加日志文件名称的拼写生成
This commit is contained in:
qiaoqinzheng 2024-01-02 18:00:29 +08:00
parent a27ddf6c2c
commit 6cf57cf41a
4 changed files with 31 additions and 5 deletions

View File

@ -42,7 +42,7 @@ public class AutoProcessManager{
/**
* 以邮件id为key以邮件执行线程为value
*/
private Map<String,Thread> emailExecThreadMap = new HashMap<>();
private Map<String,EmailParsingActuator> emailExecThreadMap = new HashMap<>();
/**
* 启动自动处理
@ -79,12 +79,17 @@ public class AutoProcessManager{
EmailProperties next = iterator.next();
if(next.isDelFlag()){
if(emailExecThreadMap.containsKey(next.getId())){
Thread thread = emailExecThreadMap.get(next.getId());
thread.interrupt();
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
actuator.interrupt();
emailExecThreadMap.remove(next.getId());
}
iterator.remove();
}
if (next.isResetFlag()) {
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
actuator.updateEmail(next);
next.setResetFlag(false);
}
if(next.isNewEmailFlag()){
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
@ -185,8 +190,14 @@ public class AutoProcessManager{
}
//如果包含邮箱id 并且 邮箱处于启用状态 将邮箱数据进行更新
if (flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())) {
putSysEmailMap(email);
log.info("{}邮箱加入监测队列",email.getEmailServerAddress());
EmailProperties properties = emailMap.get(email.getId());
//判断邮箱的用户名密码是否与原邮箱用户名密码一致
//如果不一致则进行更新
if ( !properties.getUsername().equals(email.getUsername()) || !properties.getPassword().equals(email.getPassword()) ) {
email.setResetFlag(true);
putSysEmailMap(email);
log.info("{}邮箱加入监测队列",email.getEmailServerAddress());
}
}
//如果不包含邮箱id 并且 邮箱处于启用状态 将邮箱对象存入到map中 并将新邮箱标识设置为true
if(!flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){

View File

@ -44,8 +44,15 @@ public class EmailParsingActuator extends Thread{
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
}
public void updateEmail(EmailProperties emailProperties) {
this.emailProperties = emailProperties;
}
@Override
public void run() {
if (this.isInterrupted()) {
return;
}
for(;;){
long start = System.currentTimeMillis();
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
@ -87,4 +94,6 @@ public class EmailParsingActuator extends Thread{
}
}
}
}

View File

@ -64,6 +64,7 @@ public class ErrorLogManager {
}
}else if(event.getEventType() == ErrorEventType.DYNAMIC_EVENT.getEventType()){
errorContent = event.getDynamicErrorContent();
fileName = event.getFileName().substring(0,event.getFileName().lastIndexOf(StringConstant.DOT))+SUFFIX;
}

View File

@ -23,4 +23,9 @@ public class EmailProperties extends SysEmail {
*/
private boolean delFlag;
/**
* 邮箱是否需要进行更新
*/
private boolean resetFlag;
}