本文整理匯總了PHP中Zend_Queue::receive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Queue::receive方法的具體用法?PHP Zend_Queue::receive怎麽用?PHP Zend_Queue::receive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Queue
的用法示例。
在下文中一共展示了Zend_Queue::receive方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: work
/**
* Process all pending tasks
*/
public function work()
{
while (count($task = $this->_queue->receive()) > 0) {
try {
$taskData = $task->toArray();
$this->getWorker()->execute($taskData[0]);
} catch (Exception $e) {
$this->_logger->logException($e);
}
}
}
示例2: testReceiveWillRetrieveZeroItems
/**
* @group ZF-7650
*/
public function testReceiveWillRetrieveZeroItems()
{
$options = $this->getTestConfig();
$options['name'] = '/temp-queue/ZF7650';
$queue = new Zend_Queue('Db', $options);
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
}
示例3: test_ZF_7650
public function test_ZF_7650()
{
// Zend_Queue_Adapter_Array
$queue = new Zend_Queue('Array');
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
// Zend_Queue_Adapter_Memcacheq
$driverOptions = array();
if (defined('TESTS_ZEND_QUEUE_MEMCACHEQ_HOST')) {
$driverOptions['host'] = TESTS_ZEND_QUEUE_MEMCACHEQ_HOST;
}
if (defined('TESTS_ZEND_QUEUE_MEMCACHEQ_PORT')) {
$driverOptions['port'] = TESTS_ZEND_QUEUE_MEMCACHEQ_PORT;
}
$options = array('name' => 'ZF7650', 'driverOptions' => $driverOptions);
$queue = new Zend_Queue('Memcacheq', $options);
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
// Zend_Queue_Adapter_Db
$driverOptions = array();
if (defined('TESTS_ZEND_QUEUE_DB')) {
require_once 'Zend/Json.php';
$driverOptions = Zend_Json::decode(TESTS_ZEND_QUEUE_DB);
}
$options = array('name' => '/temp-queue/ZF7650', 'options' => array(Zend_Db_Select::FOR_UPDATE => true), 'driverOptions' => $driverOptions);
$queue = new Zend_Queue('Db', $options);
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
// Zend_Queue_Adapter_Activemq
$driverOptions = array();
if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST')) {
$driverOptions['host'] = TESTS_ZEND_QUEUE_ACTIVEMQ_HOST;
}
if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT')) {
$driverOptions['port'] = TESTS_ZEND_QUEUE_ACTIVEMQ_PORT;
}
if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME')) {
$driverOptions['scheme'] = TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME;
}
$options = array('driverOptions' => $driverOptions);
$queue = new Zend_Queue('Activemq', $options);
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
}
示例4: testReceiveWillRetrieveZeroItems
/**
* @group ZF-7650
*/
public function testReceiveWillRetrieveZeroItems()
{
$options = array('driverOptions' => $this->getTestConfig());
$queue = new Zend_Queue('Activemq', $options);
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
}
示例5: testReceiveWillRetrieveZeroItems
/**
* @group ZF-7650
*/
public function testReceiveWillRetrieveZeroItems()
{
// Zend_Queue_Adapter_Array
$queue = new Zend_Queue('Array');
$queue2 = $queue->createQueue('queue');
$queue->send('My Test Message 1');
$queue->send('My Test Message 2');
$messages = $queue->receive(0);
$this->assertEquals(0, count($messages));
}
示例6: array
require $root_directory . 'config.php';
require_once $root_directory . 'include/utils/utils.php';
require_once $root_directory . 'include/utils/CommonUtils.php';
require_once $root_directory . 'include/database/PearDatabase.php';
require_once $root_directory . 'include/logging.php';
require_once $root_directory . 'modules/Users/Users.php';
require_once $root_directory . 'include/utils/clean_incoming_data.php';
require_once $root_directory . 'user_privileges/seqprefix_config.php';
require_once $root_directory . 'include/Zend/Queue.php';
global $adb;
global $site_URL;
global $dbconfig;
$options = array('name' => 'queue1', 'driverOptions' => array('host' => $dbconfig['db_server'], 'port' => substr($dbconfig['db_port'], 1), 'username' => $dbconfig['db_username'], 'password' => $dbconfig['db_password'], 'dbname' => $dbconfig['db_name'], 'type' => 'pdo_mysql'));
$queue = new Zend_Queue('Db', $options);
//一分鍾發送25條
$messages = $queue->receive(100);
foreach ($messages as $i => $message) {
//參數字符串
$postdata = $message->body;
$posts = explode("&", $postdata);
//sjid
$sjid_arr = explode("=", $posts[0]);
$sjid = $sjid_arr['1'];
//maillogsid
$maillogsid_arr = explode("=", $posts[1]);
$maillogsid = $maillogsid_arr['1'];
//判斷是否已經發送過了
$mailflag = checkMaillog($maillogsid);
if (!$mailflag) {
continue;
}