duan0504 2015-05-11 21:47
浏览 24
已采纳

如何通过SQS将任务从EC2卸载到工作人员

I have a Elastic bean EC2 with Worker setup (I use this for periodic tasks). From what I understand, the periodic tasks get queued in SQS & are read by the worker and executed as a http://localhost HTTP Post to the url we set in the cron.yaml

 - name: "db-backup"
   url: "/cron/db-backup"
   schedule: "30 21 * * *"

How do we achieve this using the AWS SDK? All I can see is just the QueueUrl and MessageBody. How do I specify the URL path i.e. /cron/db-backup

$client->sendMessage(array(
   'QueueUrl'    => $queueUrl,
   'MessageBody' => 'Hello World!',
));

Where should I specify the path /cron/db-backup? Or have I got the concept wrong?

  • 写回答

1条回答 默认 最新

  • dongliuzi3410 2015-05-13 14:18
    关注

    It turns out I was partly correct. You cannot set the HTTP path for individual messages you post to the queue but you can & do set a common path for all the messages to be delivered from where you would implementing a dispatch logic for the code flow.

    You set this when you are configuring the Worker tier & can be changed anytime from the Worker configuration section.

    Worker configuration

    If you set the MIME type as application/json you get the payload from file_get_contents('php://input') & if x-www-form-urlencoded it is going to be $_POST

    As simple as it may sound, I was completely lost considering that I can use multiple http paths (urls) when working as a periodic task. I hope this helps others as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测