如何在Java中的某个特定时间间隔后调用方法 [英] How to call a method after some specific interval of time in Java

查看:34
本文介绍了如何在Java中的某个特定时间间隔后调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是用例:

我正在使用 Java(带有 Spring)

I am using Java (with Spring)

一旦用户(通过网络应用程序)确认订阅,我想在 30 分钟后给他发送一封电子邮件.

Once the user (through a web-app) confirms to the subscription, I want to send him an email exactly after 30 mins.

现在怎么做?我需要消息代理吗?或者像ScheduledExecutorService?我需要某种队列吗?

Now how to do this? Do I need a message broker? or something like ScheduledExecutorService? Do I need some sort of queue?

请指教.

推荐答案

可以看看 quartz scheduler为了这.

顺便说一句,一个常见的策略是每 30 分钟左右批量发送所有待处理邮件.Quartz 也可以帮助做到这一点.

By the way a common strategy is to send a bulk of all pending mails in bulk in every 30 minutes or so. Quartz can help in do that as well.

这篇关于如何在Java中的某个特定时间间隔后调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆