简体   繁体   English

在PHP中使用Iron.mq推送队列

[英]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. 我正在尝试使用iron.mq推送队列,但是在弄清楚接收到消息后如何正确响应队列时遇到了困难。 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. 端点以2xx(成功)响应并被删除或4xx / 5xx失败,在这种情况下,队列将尝试将消息重新发送到端点。

For example, my script (using FuelPHP) has something like this: 例如,我的脚本(使用FuelPHP)具有以下内容:

    $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 处理消息并将成功返回到Ironmq服务器的响应
  2. Delay the process (by sending a 4xx/5xx?) and have it be resent after a defined period of time. 延迟该过程(通过发送4xx / 5xx?),并在定义的时间段后重新发送。

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. 使用PHP SDK的deleteMessage方法会导致异常,因为该消息似乎不再存在。

so - two ways: 所以-两种方式:

  1. 202 -> do long work -> deleteMessagePushStatus() 202->长时间工作-> deleteMessagePushStatus()
  2. 4xx or 5xx -> 4xx or 5xx (many times) -> 200 4xx或5xx-> 4xx或5xx(多次)-> 200

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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