Commit 58fa56b8 authored by Quxl's avatar Quxl

x

parent bacc6260
package com.egolm.pds.bean; package com.egolm.pds.bean;
public class EmailObject { public class MailObject {
public String subject; public String subject;
public String content; public String content;
} }
...@@ -12,7 +12,7 @@ import org.springframework.stereotype.Component; ...@@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.MailUtil; import com.egolm.common.MailUtil;
import com.egolm.pds.bean.EmailObject; import com.egolm.pds.bean.MailObject;
import com.egolm.pds.bean.MailConfig; import com.egolm.pds.bean.MailConfig;
import com.egolm.pds.utils.ThrowableUtil; import com.egolm.pds.utils.ThrowableUtil;
...@@ -22,12 +22,12 @@ public class EmailService { ...@@ -22,12 +22,12 @@ public class EmailService {
@Autowired @Autowired
private MailConfig config; private MailConfig config;
private static final Log log = LogFactory.getLog(EmailService.class); private static final Log log = LogFactory.getLog(EmailService.class);
private static final LinkedBlockingQueue<EmailObject> queue = new LinkedBlockingQueue<EmailObject>(); private static final LinkedBlockingQueue<MailObject> queue = new LinkedBlockingQueue<MailObject>();
public void sendForasync(String subject, String content, Throwable e) { public void sendForasync(String subject, String content, Throwable e) {
StringBuffer stackString = ThrowableUtil.toStackString(e); StringBuffer stackString = ThrowableUtil.toStackString(e);
String timeString = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); String timeString = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
EmailObject emailObject = new EmailObject(); MailObject emailObject = new MailObject();
emailObject.subject = subject; emailObject.subject = subject;
emailObject.content = timeString + "\r\n" + subject + "\r\n" + content + "\r\n" + stackString.toString(); emailObject.content = timeString + "\r\n" + subject + "\r\n" + content + "\r\n" + stackString.toString();
queue.add(emailObject); queue.add(emailObject);
...@@ -36,7 +36,7 @@ public class EmailService { ...@@ -36,7 +36,7 @@ public class EmailService {
@Scheduled(initialDelay = 5000, fixedRate = Long.MAX_VALUE) @Scheduled(initialDelay = 5000, fixedRate = Long.MAX_VALUE)
private void exec() { private void exec() {
while(true) { while(true) {
EmailObject obj = null; MailObject obj = null;
try { try {
obj = queue.take(); obj = queue.take();
this.sendForsync(obj.subject, obj.content); this.sendForsync(obj.subject, obj.content);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment