function messaging_store_queue_process_step in Messaging 6.3
Same name and namespace in other branches
- 5 messaging.store.inc \messaging_store_queue_process_step()
- 6 messaging.store.inc \messaging_store_queue_process_step()
- 6.2 messaging.store.inc \messaging_store_queue_process_step()
Retrieve and send queued messages
Parameters
$limit: Maximum number of queued messages to process for this step
$timeout: Optional time limit for processing, will return when if reached during processing
Return value
Number of messages processed in this step
1 call to messaging_store_queue_process_step()
- messaging_store_queue_process in ./
messaging.store.inc - Process and send messages in queue, to be called from cron
File
- ./
messaging.store.inc, line 62 - Database storage for the messaging framework
Code
function messaging_store_queue_process_step($limit, $timeout = 0) {
$count = 0;
$sent = $unsent = array();
$result = db_query_range("SELECT * FROM {messaging_store} WHERE queue = 1 AND cron = 1 ORDER BY mqid", 0, $limit);
while ($message = db_fetch_object($result)) {
messaging_store_unpack($message, TRUE);
// Actual sending functions function
$message->process = TRUE;
$message
->send();
if ($message->success) {
$sent[] = $message->mqid;
}
else {
$unsent[] = $message->mqid;
}
$count++;
// Check timeout after each message
if ($timeout && time() > $timeout) {
break;
}
}
if ($sent) {
messaging_store_sent($sent);
}
if ($unsent) {
messaging_store_sent($unsent, TRUE);
}
return $count;
}