Message Queuing or Scheduler

I am currently using Quartz Scheduler for asynchronous tasks, such as sending email when an exception occurs, sending email from the web interface, or periodically analyzing traffic.

Should I use message queue to send email? Is it more efficient or right to do it this way? The planner approach works very well.

If I use the queue and I cannot send the email, is it possible that the queue will retry sending the email later? The approach to the queue looks simpler than the scheduler for tasks that should be executed immediately, but for the tasks of the scheduler, the scheduler is still there if there are more queues than I know.

I haven't used JMS yet, so this is what I read.

Walter

+7
java quartz-scheduler message-queue
source share
3 answers

They are really different, and it depends on the purpose and frequency that you want to send by email. The scheduler creates a time-based event, and then runs some code to send the email. A queue has no way to trigger an event, it must have a message placed on it from somewhere, and then a MessageListener sends an email.

To answer your question, queue is a good tool for sending emails if

  • The message must be returned to the queue if the operation failed, although SMTP does not know if the mail has reached its destination.
  • Some triggers may queue.

The scheduler can run some Java code at a certain interval and, therefore, generates temporary events. If you want to send periodic emails, then the scheduler is the way to go.

If you go with the scheduler, you need the scheduler to queue the message. If not, then you need some other trigger to queue the message.

+2
source share

Queuing would be a more natural choice for sending things like email. Quartz may be charred by shoes, but this is not a natural fit when you like to try again. The scheduler is most suitable for exactly what the name suggests - tasks that should periodically occur.

+2
source share

I agree with Tom that such asynchronous communication is best done through a queue. This works as a watcher-subscription publishing model.

+1
source share