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 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题