You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/10/18 13:37:04 UTC
[shardingsphere-elasticjob] branch master updated: Polish
elasticjob-error-handler-email (#1580)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new 34b7eae Polish elasticjob-error-handler-email (#1580)
34b7eae is described below
commit 34b7eae340aefce0cb72b997c57307584e34db06
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Oct 18 21:36:54 2020 +0800
Polish elasticjob-error-handler-email (#1580)
---
.../error/handler/email/EmailJobErrorHandler.java | 96 +++++++++++-----------
.../handler/email/config/EmailConfiguration.java | 56 ++++++-------
...onstants.java => EmailPropertiesConstants.java} | 28 +++----
.../handler/email/EmailJobErrorHandlerTest.java | 24 +++---
...sphere.elasticjob.error.handler.JobErrorHandler | 18 ----
.../handler/wechat/WechatJobErrorHandlerTest.java | 14 +---
.../elasticjob/lite/example/JavaMain.java | 24 +++---
7 files changed, 112 insertions(+), 148 deletions(-)
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
index c96663f..40e9494 100644
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
+++ b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandler.java
@@ -49,43 +49,12 @@ public final class EmailJobErrorHandler implements JobErrorHandler {
private Session session;
- private synchronized Session createSession(final EmailConfiguration emailConfiguration) {
- if (null == session) {
- session = Session.getDefaultInstance(createSessionProperties(emailConfiguration), getSessionAuthenticator(emailConfiguration));
- }
- return session;
- }
-
- private Properties createSessionProperties(final EmailConfiguration emailConfiguration) {
- Properties result = new Properties();
- result.put("mail.smtp.host", emailConfiguration.getHost());
- result.put("mail.smtp.port", emailConfiguration.getPort());
- result.put("mail.smtp.auth", "true");
- result.put("mail.transport.protocol", "smtp");
- result.setProperty("mail.debug", Boolean.toString(emailConfiguration.isDebug()));
- if (emailConfiguration.isUseSsl()) {
- result.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
- result.setProperty("mail.smtp.socketFactory.fallback", "false");
- }
- return result;
- }
-
- private Authenticator getSessionAuthenticator(final EmailConfiguration emailConfiguration) {
- return new Authenticator() {
-
- @Override
- public PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(emailConfiguration.getUsername(), emailConfiguration.getPassword());
- }
- };
- }
-
@Override
public void handleException(final JobConfiguration jobConfig, final Throwable cause) {
- EmailConfiguration emailConfiguration = EmailConfiguration.getByProps(jobConfig.getProps());
- String errorContext = createErrorContext(jobConfig.getJobName(), cause);
+ EmailConfiguration emailConfig = new EmailConfiguration(jobConfig.getProps());
+ String errorMessage = getErrorMessage(jobConfig.getJobName(), cause);
try {
- sendMessage(createMessage(errorContext, emailConfiguration), emailConfiguration);
+ sendMessage(createMessage(errorMessage, emailConfig), emailConfig);
log.error("An exception has occurred in Job '{}', Notification to email was successful..", jobConfig.getJobName(), cause);
} catch (final MessagingException ex) {
cause.addSuppressed(ex);
@@ -93,46 +62,77 @@ public final class EmailJobErrorHandler implements JobErrorHandler {
}
}
- private String createErrorContext(final String jobName, final Throwable cause) {
+ private String getErrorMessage(final String jobName, final Throwable cause) {
StringWriter writer = new StringWriter();
cause.printStackTrace(new PrintWriter(writer, true));
return String.format("Job '%s' exception occur in job processing, caused by %s", jobName, writer.toString());
}
- private Message createMessage(final String content, final EmailConfiguration emailConfiguration) throws MessagingException {
- MimeMessage result = new MimeMessage(Optional.ofNullable(session).orElseGet(() -> createSession(emailConfiguration)));
- result.setFrom(new InternetAddress(emailConfiguration.getFrom()));
- result.setSubject(emailConfiguration.getSubject());
+ private Message createMessage(final String content, final EmailConfiguration emailConfig) throws MessagingException {
+ MimeMessage result = new MimeMessage(Optional.ofNullable(session).orElseGet(() -> createSession(emailConfig)));
+ result.setFrom(new InternetAddress(emailConfig.getFrom()));
+ result.setSubject(emailConfig.getSubject());
result.setSentDate(new Date());
Multipart multipart = new MimeMultipart();
BodyPart mailBody = new MimeBodyPart();
mailBody.setContent(content, "text/html; charset=utf-8");
multipart.addBodyPart(mailBody);
result.setContent(multipart);
- String to = emailConfiguration.getTo();
+ String to = emailConfig.getTo();
if (StringUtils.isNotBlank(to)) {
String[] tos = to.split(",");
- for (String t : tos) {
- result.addRecipient(Message.RecipientType.TO, new InternetAddress(t));
+ for (String each : tos) {
+ result.addRecipient(Message.RecipientType.TO, new InternetAddress(each));
}
}
- if (StringUtils.isNotBlank(emailConfiguration.getCc())) {
- result.addRecipient(Message.RecipientType.CC, new InternetAddress(emailConfiguration.getCc()));
+ if (StringUtils.isNotBlank(emailConfig.getCc())) {
+ result.addRecipient(Message.RecipientType.CC, new InternetAddress(emailConfig.getCc()));
}
- if (StringUtils.isNotBlank(emailConfiguration.getBcc())) {
- result.addRecipient(Message.RecipientType.BCC, new InternetAddress(emailConfiguration.getBcc()));
+ if (StringUtils.isNotBlank(emailConfig.getBcc())) {
+ result.addRecipient(Message.RecipientType.BCC, new InternetAddress(emailConfig.getBcc()));
}
result.saveChanges();
return result;
}
- private void sendMessage(final Message message, final EmailConfiguration emailConfiguration) throws MessagingException {
- try (Transport transport = Optional.ofNullable(session).orElseGet(() -> createSession(emailConfiguration)).getTransport()) {
+ private void sendMessage(final Message message, final EmailConfiguration emailConfig) throws MessagingException {
+ try (Transport transport = Optional.ofNullable(session).orElseGet(() -> createSession(emailConfig)).getTransport()) {
transport.connect();
transport.sendMessage(message, message.getAllRecipients());
}
}
+ private synchronized Session createSession(final EmailConfiguration emailConfig) {
+ if (null == session) {
+ session = Session.getDefaultInstance(createSessionProperties(emailConfig), getSessionAuthenticator(emailConfig));
+ }
+ return session;
+ }
+
+ private Properties createSessionProperties(final EmailConfiguration emailConfig) {
+ Properties result = new Properties();
+ result.put("mail.smtp.host", emailConfig.getHost());
+ result.put("mail.smtp.port", emailConfig.getPort());
+ result.put("mail.smtp.auth", "true");
+ result.put("mail.transport.protocol", "smtp");
+ result.setProperty("mail.debug", Boolean.toString(emailConfig.isDebug()));
+ if (emailConfig.isUseSsl()) {
+ result.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
+ result.setProperty("mail.smtp.socketFactory.fallback", "false");
+ }
+ return result;
+ }
+
+ private Authenticator getSessionAuthenticator(final EmailConfiguration emailConfig) {
+ return new Authenticator() {
+
+ @Override
+ public PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(emailConfig.getUsername(), emailConfig.getPassword());
+ }
+ };
+ }
+
@Override
public String getType() {
return "EMAIL";
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConfiguration.java b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConfiguration.java
index 65c2bc2..9db5c22 100644
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConfiguration.java
+++ b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConfiguration.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.elasticjob.error.handler.email.config;
import lombok.Getter;
-import lombok.Setter;
import java.util.Properties;
@@ -26,50 +25,41 @@ import java.util.Properties;
* Job error handler configuration for send error message via email.
*/
@Getter
-@Setter
public final class EmailConfiguration {
- private String host;
+ private final String host;
- private Integer port;
+ private final int port;
- private String username;
+ private final String username;
- private String password;
+ private final String password;
- private boolean useSsl;
+ private final boolean useSsl;
- private String subject;
+ private final String subject;
- private String from;
+ private final String from;
- private String to;
+ private final String to;
- private String cc;
+ private final String cc;
- private String bcc;
+ private final String bcc;
- private boolean debug;
+ private final boolean debug;
- /**
- * Get email configuration.
- *
- * @param props properties
- * @return email configuration
- */
- public static EmailConfiguration getByProps(final Properties props) {
- EmailConfiguration result = new EmailConfiguration();
- result.setHost(props.getProperty(EmailConstants.EMAIL_HOST));
- result.setPort(Integer.parseInt(props.getProperty(EmailConstants.EMAIL_PORT)));
- result.setUsername(props.getProperty(EmailConstants.EMAIL_USERNAME));
- result.setPassword(props.getProperty(EmailConstants.EMAIL_PASSWORD));
- result.setUseSsl(Boolean.parseBoolean(props.getOrDefault(EmailConstants.EMAIL_USE_SSL, Boolean.FALSE.toString()).toString()));
- result.setSubject(props.getOrDefault(EmailConstants.EMAIL_SUBJECT, EmailConstants.DEFAULT_EMAIL_SUBJECT).toString());
- result.setFrom(props.getProperty(EmailConstants.EMAIL_FROM));
- result.setTo(props.getProperty(EmailConstants.EMAIL_TO));
- result.setCc(props.getProperty(EmailConstants.EMAIL_CC));
- result.setBcc(props.getProperty(EmailConstants.EMAIL_BCC));
- result.setDebug(Boolean.parseBoolean(props.getOrDefault(EmailConstants.EMAIL_DEBUG, Boolean.FALSE.toString()).toString()));
- return result;
+ public EmailConfiguration(final Properties props) {
+ host = props.getProperty(EmailPropertiesConstants.HOST);
+ port = Integer.parseInt(props.getProperty(EmailPropertiesConstants.PORT));
+ username = props.getProperty(EmailPropertiesConstants.USERNAME);
+ password = props.getProperty(EmailPropertiesConstants.PASSWORD);
+ useSsl = Boolean.parseBoolean(props.getProperty(EmailPropertiesConstants.IS_USE_SSL, Boolean.FALSE.toString()));
+ subject = props.getProperty(EmailPropertiesConstants.SUBJECT, EmailPropertiesConstants.DEFAULT_SUBJECT);
+ from = props.getProperty(EmailPropertiesConstants.FROM);
+ to = props.getProperty(EmailPropertiesConstants.TO);
+ cc = props.getProperty(EmailPropertiesConstants.CC);
+ bcc = props.getProperty(EmailPropertiesConstants.BCC);
+ debug = Boolean.parseBoolean(props.getProperty(EmailPropertiesConstants.IS_DEBUG, Boolean.FALSE.toString()));
}
}
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConstants.java b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailPropertiesConstants.java
similarity index 54%
rename from elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConstants.java
rename to elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailPropertiesConstants.java
index 4f0712a..c9f47f7 100644
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailConstants.java
+++ b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/config/EmailPropertiesConstants.java
@@ -20,31 +20,31 @@ package org.apache.shardingsphere.elasticjob.error.handler.email.config;
/**
* Job error handler properties constants for send error message via email.
*/
-public final class EmailConstants {
+public final class EmailPropertiesConstants {
- public static final String PREFIX = "email.";
+ public static final String DEFAULT_SUBJECT = "ElasticJob error message";
- public static final String EMAIL_HOST = PREFIX + "host";
+ private static final String PREFIX = "email.";
- public static final String EMAIL_PORT = PREFIX + "port";
+ public static final String HOST = PREFIX + "host";
- public static final String EMAIL_USERNAME = PREFIX + "username";
+ public static final String PORT = PREFIX + "port";
- public static final String EMAIL_PASSWORD = PREFIX + "password";
+ public static final String USERNAME = PREFIX + "username";
- public static final String EMAIL_USE_SSL = PREFIX + "useSsl";
+ public static final String PASSWORD = PREFIX + "password";
- public static final String EMAIL_SUBJECT = PREFIX + "subject";
+ public static final String IS_USE_SSL = PREFIX + "useSsl";
- public static final String EMAIL_FROM = PREFIX + "from";
+ public static final String SUBJECT = PREFIX + "subject";
- public static final String EMAIL_TO = PREFIX + "to";
+ public static final String FROM = PREFIX + "from";
- public static final String EMAIL_CC = PREFIX + "cc";
+ public static final String TO = PREFIX + "to";
- public static final String EMAIL_BCC = PREFIX + "bcc";
+ public static final String CC = PREFIX + "cc";
- public static final String EMAIL_DEBUG = PREFIX + "debug";
+ public static final String BCC = PREFIX + "bcc";
- public static final String DEFAULT_EMAIL_SUBJECT = "ElasticJob error message";
+ public static final String IS_DEBUG = PREFIX + "debug";
}
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
index 5d3188a..816da79 100644
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
+++ b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.email;
import lombok.SneakyThrows;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerFactory;
-import org.apache.shardingsphere.elasticjob.error.handler.email.config.EmailConstants;
+import org.apache.shardingsphere.elasticjob.error.handler.email.config.EmailPropertiesConstants;
import org.apache.shardingsphere.elasticjob.infra.exception.JobConfigurationException;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -60,17 +60,17 @@ public final class EmailJobErrorHandlerTest {
private JobConfiguration getJobConfiguration() {
return JobConfiguration.newBuilder("test_job", 3)
- .setProperty(EmailConstants.EMAIL_HOST, "xxx")
- .setProperty(EmailConstants.EMAIL_PORT, "465")
- .setProperty(EmailConstants.EMAIL_USERNAME, "xxx")
- .setProperty(EmailConstants.EMAIL_PASSWORD, "xxx")
- .setProperty(EmailConstants.EMAIL_USE_SSL, "true")
- .setProperty(EmailConstants.EMAIL_SUBJECT, "Unit test notification")
- .setProperty(EmailConstants.EMAIL_FROM, "from@xxx.com")
- .setProperty(EmailConstants.EMAIL_TO, "to1@xxx.com,to2@xxx.com")
- .setProperty(EmailConstants.EMAIL_CC, "cc@xxx.com")
- .setProperty(EmailConstants.EMAIL_BCC, "bcc@xxx.com")
- .setProperty(EmailConstants.EMAIL_DEBUG, "false")
+ .setProperty(EmailPropertiesConstants.HOST, "xxx")
+ .setProperty(EmailPropertiesConstants.PORT, "465")
+ .setProperty(EmailPropertiesConstants.USERNAME, "xxx")
+ .setProperty(EmailPropertiesConstants.PASSWORD, "xxx")
+ .setProperty(EmailPropertiesConstants.IS_USE_SSL, "true")
+ .setProperty(EmailPropertiesConstants.SUBJECT, "Unit test notification")
+ .setProperty(EmailPropertiesConstants.FROM, "from@xxx.com")
+ .setProperty(EmailPropertiesConstants.TO, "to1@xxx.com,to2@xxx.com")
+ .setProperty(EmailPropertiesConstants.CC, "cc@xxx.com")
+ .setProperty(EmailPropertiesConstants.BCC, "bcc@xxx.com")
+ .setProperty(EmailPropertiesConstants.IS_DEBUG, "false")
.build();
}
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/resources/META-INF.services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/resources/META-INF.services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler
deleted file mode 100644
index 3096707..0000000
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/resources/META-INF.services/org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandler
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.elasticjob.error.handler.email.EmailJobErrorHandler
diff --git a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java
index 72db81a..c668c30 100644
--- a/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java
+++ b/elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerTest.java
@@ -37,8 +37,6 @@ import org.slf4j.Logger;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@@ -104,11 +102,9 @@ public final class WechatJobErrorHandlerTest {
actual.handleException(getJobConfiguration("http://localhost:9872/404"), cause);
verify(log).error("An exception has occurred in Job '{}', But failed to send alert by wechat because of: Unexpected response status: {}", "test_job", 404, cause);
}
-
- @Test
- public void assertGetType() {
- WechatJobErrorHandler actual = getWechatJobErrorHandler();
- assertThat(actual.getType(), is("WECHAT"));
+
+ private WechatJobErrorHandler getWechatJobErrorHandler() {
+ return (WechatJobErrorHandler) JobErrorHandlerFactory.createHandler("WECHAT").orElseThrow(() -> new JobConfigurationException("WECHAT error handler not found."));
}
@SneakyThrows
@@ -128,8 +124,4 @@ public final class WechatJobErrorHandlerTest {
.setProperty(WechatPropertiesConstants.READ_TIMEOUT_MILLISECOND, "2000")
.build();
}
-
- private WechatJobErrorHandler getWechatJobErrorHandler() {
- return (WechatJobErrorHandler) JobErrorHandlerFactory.createHandler("WECHAT").orElseThrow(() -> new JobConfigurationException("WECHAT error handler not found."));
- }
}
diff --git a/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java b/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
index 6c4f84d..c584911 100644
--- a/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
+++ b/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.elasticjob.lite.example;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.shardingsphere.elasticjob.error.handler.dingtalk.config.DingtalkPropertiesConstants;
-import org.apache.shardingsphere.elasticjob.error.handler.email.config.EmailConstants;
+import org.apache.shardingsphere.elasticjob.error.handler.email.config.EmailPropertiesConstants;
import org.apache.shardingsphere.elasticjob.error.handler.wechat.config.WechatPropertiesConstants;
import org.apache.shardingsphere.elasticjob.http.props.HttpJobProperties;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.OneOffJobBootstrap;
@@ -159,17 +159,17 @@ public final class JavaMain {
}
private static void setEmailConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_HOST, "host");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_PORT, "465");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_USERNAME, "username");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_PASSWORD, "password");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_USE_SSL, "true");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_SUBJECT, "Test elasticJob error message");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_FROM, "from@xxx.com");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_TO, "to1@xxx.com,to2xxx.com");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_CC, "cc@xxx.com");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_BCC, "bcc@xxx.com");
- jobConfig.getProps().setProperty(EmailConstants.EMAIL_DEBUG, "false");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.HOST, "host");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.PORT, "465");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.USERNAME, "username");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.PASSWORD, "password");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.IS_USE_SSL, "true");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.SUBJECT, "Test elasticJob error message");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.FROM, "from@xxx.com");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.TO, "to1@xxx.com,to2xxx.com");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.CC, "cc@xxx.com");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.BCC, "bcc@xxx.com");
+ jobConfig.getProps().setProperty(EmailPropertiesConstants.IS_DEBUG, "false");
}
private static String buildScriptCommandLine() throws IOException {