How do I handle push messages from IronMQ when my endpoint is an IronWorker?

432 views Asked by At

The documentation for IronMQ push queues describes how endpoints should handle/respond to push messages. However, I get the impression this is for normal webhooks and I can't find any documentation or examples of what to do when the endpoint for a push queue is an IronWorker.

Does the IronWorker framework take care of responding to the IronMQ service when it starts a new IronWorker task for the message pushed onto the queue, or does my IronWorker code need to handle the response? If I need to handle it in my code, are there any variables automatically provided to me that represent the webhook request and/or response?

As I mentioned above, I've looked for example code but all I've found are IronWorker webhook examples that receive POSTs from something like GitHub, not from IronMQ. If there are examples out there for what I'm trying to do please point me to it!

2

There are 2 answers

0
thousandsofthem On

IronWorker API will respond immediately for a post request with "HTTP 200 OK" status and queue a task after that, it's too late to respond something from running task.

You could find exact webhook value on "Code" page (https://hud.iron.io). Screenshot: https://i.stack.imgur.com/kf5D4.png Just use it "as is"

0
Travis Reeder On

There's actually a special subscriber format just for IronWorker as specified in the Push Queue documentation here: http://dev.iron.io/mq/reference/push_queues/#subscribers . Eg:

ironworker:///my_worker

That will kick off a worker task whenever something hits your queue. Or you can use the worker's webhook URL. And you don't need to deal with the response, as @thousandsofthem said, IronWorker will return a 200 which acknowledges the pushed message.