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?
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.
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.