Question about benstalkd queue

I want to add two phase authentication in my website login process, thus I want to send an SMS to my user with random access code, benstalkd can help to asynchronous send the message, and improvement user experience. And you can easy to see, this is a time sensitive process, so it cannot be added into crontab, I want my send process can be notified when a new job put into the queue.

Any idea? Thanks in advanced.

index.php

$di->set('queue', function() use ($config) {
    $queue = new Phalcon\Queue\Beanstalk(array(
        'host' => $config->queue->host,
        'port' => $config->queue->port
    ));

    return $queue;
});


16.3k

register a callback function or observer? how?



16.3k

How about:

!/usr/local/bin/php -q

<?php // Stop the script giving time out errors.. settimelimit(0);

// Main loop while(true) { $queue = new Phalcon\Queue\Beanstalk(array( 'host' => '127.0.0.1', 'port' => 11300 )); while (($job = $this->queue->peekReady()) !== false) { $job = $this->queue->reserve(); $message = $job->getBody();

    //...

    $job->delete();
}
sleep(1);

}