简体   繁体   中英

RabbitMQ : Sending mail by schedule in Spring Boot?

In my Spring Boot app, I implement an endpoint to send email to a single user. At this stage, I need the following implementations:

  • Sending mail to multiple users (less than 100 users)
  • Schedule sending time

My questions:

1. Although I have no previous experience for RabbitMQ, I want to start to use it and I think I can use it for sending email to multiple user. Is this scenario suitable for using RabbitMQ?

2. At this stage, I think of using a proper scheduler for Spring Boot. Does RabbitMQ supports scheduling to periadically send mail to multiple user? If not, which library should I use for scheduling that is suitable for Spring Boot and RabbitMQ?

No, RabbitMQ should not be used as a task scheduler. RabbitMQ is a message broker (for example, sending a message from one microservice to another).

For tasks scheduling, you can use the ScheduledThreadPoolExecutor / Timer ,/ Quartz (see: github repo )/ Spring Scheduler ...

Example: you can create a microservice that, using RabbitMQ, will receive asynchronous tasks to send/schedule emails, using, for example, Quartz + JDBC + Spring-mail.

I also advise you to look at the examples below:

example with Quartz + MySQL + SpringBoot

another example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM