0

很抱歉,如果这是重复的,我尝试搜索这个,但不确定要使用什么搜索词并且没有真正找到任何东西。

我有一个 Ruby on Rails 应用程序,该应用程序将用于向用户发送文本消息,其中包含指向可能使用 clickatell 的多项选择问题的链接。这些问题有一个与之相关的日期和时间。我想让 ruby​​ on rails 应用程序在指定日期自动将这些 SMS 消息发送到用户的手机。

我真的不知道如何去做这件事。谁能指出我在 ruby​​ on rails 中安排此类事件的大致方向。我不需要一个确切的解决方案,也许如果有人可以澄清这到底是什么,那么我可以在网上找到一些资源。

谢谢

4

2 回答 2

1

似乎不再发送您的问题?在这种情况下,我不会通过 cronjob 执行此操作。我会通过以下方式做到这一点:https ://github.com/bvandenbos/resque-scheduler

因此,每当安排一个问题时,您只需将其添加到延迟队列中,resque-scheduler 就会在时间到时将它们移动到正确的工作队列中。

这样您就不必担心某种轮询 cronjob,这将由 resque-scheduler 自动完成。您还可以免费获得通过 resque 发送短信的异步处理。因此,如果您必须发送大量短信,您可以并行运行它们。

所以它会是这样的:

  1. 保存问题后,您将在延迟队列中排队,以便将来发送问题
  2. when the date comes up, the message is moved onto 'ready to send'-queue, which is in charge of gathering all the users the question needs to be sent to.
  3. for each of those users you create another message on the 'ready to send'-queue
  4. the 'ready to send'-queue will then send out the actual SMSes

You then can run many workers on the 'ready to send'-queue and have the SMSes be sent out in parallel. You also get error handling for free with resque, it gahers all messages that resulted in an exception in a 'failure' queue, which you can then debug or reschedule again

于 2013-03-29T20:53:16.783 回答
0

您可以使用when来安排事件。

于 2013-03-29T19:41:35.153 回答