Announcement Announcement Module
Collapse
No announcement yet.
@Async problem - method work partially Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Async problem - method work partially

    Hi, I'm not sure if this is good place to post my question, but I hope it's ok. So I want to send email in method annotated with @Async. This method looks like this:
    Code:
    @Async
        public void sendRegistrationEmail(String name, String email, String password) throws MessagingException {
            System.out.println("sending registration email");
            MimeMultipart multipart = new MimeMultipart("registration");
    
                MimeBodyPart messageBodyPart = new MimeBodyPart();
                StringBuffer htmlText = new StringBuffer(MessagesUtils.getMessage("mcv.msg.registerOk1"));
                htmlText.append(name);
                htmlText.append(MessagesUtils.getMessage("mcv.msg.registerOk2"));
                htmlText.append(email);
                htmlText.append(MessagesUtils.getMessage("mcv.msg.registerOk3"));
                htmlText.append(password);
                htmlText.append(MessagesUtils.getMessage("mcv.msg.registerOk4"));
    
                messageBodyPart.setContent(htmlText.toString(), "text/html; charset=UTF-8");
    
                multipart.addBodyPart(messageBodyPart);
    
            System.out.println("sending registration email 2");
    ...
    ...
    After invoking this method "sending registration email" appears but "sending registration email 2" doesn't. Can anybody can tell me why? Any help would be appreciated. Thank you in advance.

  • #2
    Maybe it's because of static method getting messages? I removed them and it's working.

    Comment

    Working...
    X