如何根据数据库中的时间戳触发警报?
场景:
有一个任务管理器应用程序,允许用户创建任务并将时间戳与其关联。
目标:
应用程序应该在用户的任何任务到期时向用户发送电子邮件警报。
问题:
应用程序中是否有一个函数 sendEmailAlerts
,它可以查询数据库、获取所有现在到期的任务,并向其创建者发送提醒; 是否可以在任务到期时恰好触发此函数?
我想到的方法是使用 Quartz 作业,该作业每 x 分钟运行一次并调用 sendEmailAlerts 。但这种方法似乎效率并不高。有更好的方法吗?
感谢您的帮助。
Scenario:
There's a task-manager application that allows its users to create tasks and associate a timestamp with it.
Goal:
The application is supposed to send email alerts to the users at the time when any of their tasks are due.
Question:
If there's a function in the application sendEmailAlerts
, which queries database, fetches all those tasks which are due now, and send their creators alerts; is it possible to trigger this function exactly at the moment when a task is due?
The approach that I have in mind is to use a Quartz job, that would run every x minutes and invoke sendEmailAlerts
. But this approach doesn't seem very efficient. Is there any better way of doing it?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您可以使用 SQL Server 代理创建一个在指定时间执行的作业,尽管在这种情况下,我认为为 x 个警报创建 x 个作业并不是最佳选择。
You could use SQL Server Agent to create a job to execute at a specified time, although in this scenario i don't think it's optimal to create x jobs for x alerts.