如何在 Elastic Beanstalk 服务器上模拟发送周期性任务? [英] How to simulate sending periodic task on Elastic Beanstalk server?

查看:27
本文介绍了如何在 Elastic Beanstalk 服务器上模拟发送周期性任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个 Elastic Beanstalk 服务器,工作层.它有一个 cron.yaml 每小时运行一个任务,如下所示:

I have set up an Elastic Beanstalk server, worker tier. It has a cron.yaml to run a task every hour, like so:

version: 1
cron:
 - name: "broadcast-users"
   url: "/broadcast"
   schedule: "0 * * * *"

我知道它通过 SQS 向工作队列发送一条消息,然后该队列被该路由接收 - 但我不知道该消息是什么样的.我希望能够轻松测试 cron 作业,而无需等待预定时间到来.

I know that it works via SQS sending a message to the worker queue which then gets picked up by that route - but I don't know what that message looks like. I would like to be able to test the cron job easily, without waiting for the scheduled time to come.

有没有人从 SQS 发出什么消息来启动这项 cron 工作?(或者我如何检查发送到 SQS 的消息的内容?)

Does anybody what the message would look like from SQS to kick off this cron job? (Or how I can inspect the contents of the messages being sent to SQS?)

谢谢!

推荐答案

如果您从 AWS SQS 控制台发送,试试这个,

If you are sending from the AWS SQS console, try this,

Message Body选项卡中,输入elasticbeanstalk schedule job.

Message Attributes中,输入以下内容:

Name: beanstalk.sqsd.path
Type: String
Value: jobs/example-job <- Whatever the URL of  your job is

Name: beanstalk.sqsd.scheduled_time
Type: String
Value: '2018-04-07T20:38:00-04:00' <- When you want it scheduled

请注意,对于 beanstalk.sqsd.path 值,如果包含前导斜杠,例如,我无法使其工作/jobs/example-job 导致队列中出现一条孤独的消息,而 jobs/example-job 起作用.

Note that for the beanstalk.sqsd.path value, I wasn't able to get it to work if I include a leading slash, e.g. /jobs/example-job resulted in a lonely message in queue whereas jobs/example-job worked.

在我的 cron.yaml 中,我将 URL 指定为 /jobs/example-job,以防您想知道.

In my cron.yaml I specified the URL to be /jobs/example-job, in case you're wondering.

这篇关于如何在 Elastic Beanstalk 服务器上模拟发送周期性任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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