Hi,
I am trying to send e-mail asynchronously but I successfully ran into troubleI have 2 methods in same class. Annotating one methods with @Async leads to running method asynchornously. Annotating second method with @Async doesn't work. This is that class simplified:
This works perfect:Code:import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @Service public class EmailService { public void sendEmailsFromTemplate(Collection<User> to, String templateName, String... args) { // load templates .... // send emails sendEmails(to, subject, message); } public void sendEmails(Collection<User> to, String subject, String message) { for (User user : to) { sendEmail(user.getEmail(), subject, message); } } private void sendEmail(String to, String subject, String message) { // do real email sending ... } }
But annotatingCode:@Async public void sendEmailsFromTemplate(Collection<User> to, String templateName, String... args)
doesn't work. Why it doesnt work?Code:@Async public void sendEmails(Collection<User> to, String subject, String message)


I have 2 methods in same class. Annotating one methods with @Async leads to running method asynchornously. Annotating second method with @Async doesn't work. This is that class simplified:
Reply With Quote
