Skip to content

Commit

Permalink
add mail logger
Browse files Browse the repository at this point in the history
  • Loading branch information
smartloli committed Apr 8, 2020
1 parent f2e8d15 commit 215a10b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smartloli.kafka.eagle.common.protocol.alarm.queue.BaseJobContext;
import org.smartloli.kafka.eagle.common.util.HttpClientUtils;
import org.smartloli.kafka.eagle.common.util.KConstants.AlarmQueue;
Expand All @@ -40,6 +42,8 @@
*/
public class MailJob implements Job {

private Logger LOG = LoggerFactory.getLogger(MailJob.class);

/** Send alarm information by mail. */
public void execute(JobExecutionContext jobContext) throws JobExecutionException {
BaseJobContext bjc = (BaseJobContext) jobContext.getJobDetail().getJobDataMap().get(AlarmQueue.JOB_PARAMS);
Expand All @@ -51,9 +55,10 @@ private int sendMsg(String data, String url) {
JSONObject object = JSON.parseObject(data);
BasicNameValuePair address = new BasicNameValuePair("address", object.getString("address"));
BasicNameValuePair msg = new BasicNameValuePair("msg", object.getString("msg"));
HttpClientUtils.doPostForm(url, Arrays.asList(address,msg));
HttpClientUtils.doPostForm(url, Arrays.asList(address, msg));
} catch (Exception e) {
ThrowExceptionUtils.print(this.getClass()).error("Send alarm message has error by mail, msg is ",e);
ThrowExceptionUtils.print(this.getClass()).error("Send alarm message has error by mail, msg is ", e);
LOG.error("Send alarm message has error by mail, msg is ", e);
return 0;
}
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ kafka.eagle.metrics.retain=15
# kafka sql topic records max
######################################
kafka.eagle.sql.topic.records.max=5000
kafka.eagle.sql.fix.error=false
kafka.eagle.sql.fix.error=true

######################################
# delete kafka topic token
Expand Down

0 comments on commit 215a10b

Please sign in to comment.