iron-io / iron_mq_php

PHP client for IronMQ.
www.iron.io
BSD 2-Clause "Simplified" License
89 stars 43 forks source link

Calling deleteMessagePushStatus() getting 404 #57

Open nodesocket opened 9 years ago

nodesocket commented 9 years ago

Recently we've been seeing an error when deleting/acknowledging an IronMQ message.

// The call looks like
$ironmq->deleteMessagePushStatus(..., ..., ...);

Response is a 404 with:

 Message not found.

Initially we thought we must be calling deleteMessagePushStatus() multiple times, but after checking our code, there is only a single call.

What is happening?

nodesocket commented 9 years ago

Anybody?

Stephenitis commented 9 years ago

are you setting a timeout on your message that you place on the queue? (if not the default is still 60 seconds) how long does the GET, processing, and then send a DELETE?

if could be possible after the first consumer does a GET if 60 seconds(timeout) passes the message ends up back on the queue and is processed by a 2nd consumer. the first consumer sends the delete request which gets received successfully and the second consumer gets a 404 when it attempts a delete.

nodesocket commented 9 years ago

So, we create a queue for each message (push) and then queue a message. The exact code is like:

////
// Create the IronMQ queue
//
//  Unicast queue
//      80 retries every 15 seconds, total retry time of 20 minutes.
////
$ironmq_options = array(
    "push_type" => "unicast",
    "retries" => 80,
    "retries_delay" => 15,
    "subscribers" => array(
        array(
            "url" => $subscriber_url,
            "headers" => $ironmq_http_headers
        )
     ),
    "error_queue" => "error-api-executions"
);

$ironmq_queue = $ironmq->updateQueue($ironmq_queue_name, $ironmq_options);

////
// Send the message to the newly created IronMQ queue
//
// Timeout after 20 minutes.
////
$ironmq_response = $ironmq->postMessage($ironmq_queue_name, $json_payload, array(
    "timeout" => 60*20
));

Total time from creating the queue and adding the message to trying to delete it is fast. Basically, as long as it takes Iron.io to send the message to the push endpoint. One of the first things the push endpoint does, is delete the message and queue. So let's call it less than 250ms once Iron.io sends the message to the push endpoint.