简体   繁体   中英

Using Iron.mq push queue with PHP

I'm attempting to use the iron.mq push queue, but am having difficulty figuring out how to properly respond to the queue after receiving a message. I realize that I might also not fully understand how the queue system behaves, but my understanding is that it is something like this:

  1. Message sent to queue
  2. Message pushed from queue to my endpoint
  3. Message is 'reserved' until my endpoint responds or times out
  4. Endpoint responds with either a 2xx (success) and it is deleted or 4xx/5xx failure, in which case the queue will attempt to resend the message to the endpoint.

For example, my script (using FuelPHP) has something like this:

    $headers = Input::headers(); //gets array of headers sent from ironmq
    $data = @file_get_contents('php://input'); //get the body

Now that I have received the message, I want to do one of two things:

  1. Process message and return response to ironmq servers that it was successful
  2. Delay the process (by sending a 4xx/5xx?) and have it be resent after a defined period of time.

But... how do you respond to a push message? Using the PHP SDK's deleteMessage method causes an exception as the message appears to no longer exist.

so - two ways:

  1. 202 -> do long work -> deleteMessagePushStatus()
  2. 4xx or 5xx -> 4xx or 5xx (many times) -> 200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM