make from-address of service-email configurable

This commit is contained in:
peter 2013-05-25 15:48:31 +02:00
parent f52ab72b7a
commit 3b01d27a1d

View File

@ -26,7 +26,7 @@ import javax.naming.InitialContext;
public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener { public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener {
private static final String VERSION_NO = "1.1"; private static final String VERSION_NO = "1.1.1";
private Logger logger; private Logger logger;
private QueueConnection conn; private QueueConnection conn;
@ -37,6 +37,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
private String jmsSystemQueue; private String jmsSystemQueue;
private String jmsFactory; private String jmsFactory;
private String serviceEMail; private String serviceEMail;
private String fromEMail;
/** /**
* Runs the QueueServer, using the arguments as ConnectionFactory * Runs the QueueServer, using the arguments as ConnectionFactory
@ -63,6 +64,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
qServ.setJmsUserName(props.getProperty("hsadmin.jms.username")); qServ.setJmsUserName(props.getProperty("hsadmin.jms.username"));
qServ.setJmsPassWord(props.getProperty("hsadmin.jms.password")); qServ.setJmsPassWord(props.getProperty("hsadmin.jms.password"));
qServ.setServiceEMail(props.getProperty("hsadmin.log.email")); qServ.setServiceEMail(props.getProperty("hsadmin.log.email"));
qServ.setFromEMail(props.getProperty("hsadmin.log.from"));
Logger logger = Logger.getLogger("de.hsadmin.core.qserv"); Logger logger = Logger.getLogger("de.hsadmin.core.qserv");
logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:" logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:"
+ "\nqueue server: " + props.getProperty("hsadmin.jms.factory") + "\nqueue server: " + props.getProperty("hsadmin.jms.factory")
@ -109,6 +111,14 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
} }
} }
private void setFromEMail(String emailAddress) {
if (emailAddress == null || emailAddress.isEmpty()) {
fromEMail = "hsadmin@hostsharing.net";
} else {
fromEMail = emailAddress;
}
}
private boolean connect() { private boolean connect() {
// create JMS connection and session // create JMS connection and session
try { try {
@ -145,7 +155,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
} catch (ProcessorException e) { } catch (ProcessorException e) {
logException(e); logException(e);
task.setException(e); task.setException(e);
SmtpHelper.send("hostmaster@hostsharing.net", serviceEMail, jmsSystemQueue, processor.logInfo()); SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo());
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
logException(throwable); logException(throwable);