Skip to content

Commit

Permalink
Merge pull request #111 from NTOU-Auction/development
Browse files Browse the repository at this point in the history
fix: Make Mail Service methods asynchronous to prevent congestion.
  • Loading branch information
Shih-Hsuan authored Aug 17, 2024
2 parents 8e25495 + bbcf6d8 commit a6be31a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.sql.DataSource;

@SpringBootApplication
@EnableScheduling
@EnableAsync
public class NtouAuctionJavaApplication {

public static void main(String[] args) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ntou/auction/spring/mail/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessagePreparator;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Date;
Expand All @@ -26,6 +27,7 @@ public EmailService(JavaMailSender mailSender, UserService userService, AppConfi
this.appConfig = appConfig;
}

@Async
public void sendMailBidSuccess(Long userId, Product product) {

if (userService.get(userId).isEmpty()) {
Expand Down Expand Up @@ -89,6 +91,7 @@ public void sendMailBidFailed(Long userId, Product product) {
}
}
*/
@Async
public void sendMailOrderEstablished(Long userId, Order order) {

if (userService.get(userId).isEmpty() || userService.get(order.getSellerid()).isEmpty()) {
Expand Down Expand Up @@ -139,6 +142,7 @@ public void sendMailOrderEstablished(Long userId, Order order) {
}
}

@Async
public void sendMailOrderUpdate(Long userId, Order order) {

if (userService.get(userId).isEmpty() || userService.get(order.getSellerid()).isEmpty()) {
Expand Down

0 comments on commit a6be31a

Please sign in to comment.