Odesílání mailů se spouští asynchronně, takže se neblokuje UI.

multitenant
Josef Rokos 11 years ago
parent 26f02b97fe
commit 42e0babcaa

@ -8,6 +8,7 @@ import org.springframework.core.io.InputStreamSource;
import org.springframework.mail.MailParseException; import org.springframework.mail.MailParseException;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
public class MailerWithAttachement implements Mailer { public class MailerWithAttachement implements Mailer {
@ -19,6 +20,7 @@ public class MailerWithAttachement implements Mailer {
} }
@Override @Override
@Async
public void send(MailMessage message) { public void send(MailMessage message) {
MimeMessage mimeMessage = sender.createMimeMessage(); MimeMessage mimeMessage = sender.createMimeMessage();

@ -1,6 +1,7 @@
package info.bukova.isspst.mail; package info.bukova.isspst.mail;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
public class SimpleMailer implements Mailer { public class SimpleMailer implements Mailer {
@ -12,6 +13,7 @@ public class SimpleMailer implements Mailer {
} }
@Override @Override
@Async
public void send(MailMessage message) { public void send(MailMessage message) {
if (message.getFrom() == null || message.getFrom().isEmpty()) { if (message.getFrom() == null || message.getFrom().isEmpty()) {
if (from == null || from.isEmpty()) { if (from == null || from.isEmpty()) {

@ -1,16 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<!-- Root Context: defines shared resources visible to all other web components --> <!-- Root Context: defines shared resources visible to all other web components -->
<context:annotation-config /> <context:annotation-config />
<context:component-scan base-package="info.bukova.isspst,org.zkoss.spring.beans.zkcomponents"></context:component-scan> <context:component-scan base-package="info.bukova.isspst,org.zkoss.spring.beans.zkcomponents"></context:component-scan>
<task:annotation-driven/>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer">
<property name="locations"> <property name="locations">
<list> <list>

Loading…
Cancel
Save