コード例 #1
0
ファイル: ZendQueue.php プロジェクト: zendframework/zendcloud
 /**
  * Create a queue. Returns the ID of the created queue (typically the URL).
  * It may take some time to create the queue. Check your vendor's
  * documentation for details.
  *
  * @param  string $name
  * @param  array  $options
  * @return string Queue ID (typically URL)
  */
 public function createQueue($name, $options = null)
 {
     try {
         $this->_queues[$name] = $this->_queue->createQueue($name, isset($options[Queue::TIMEOUT]) ? $options[Queue::TIMEOUT] : null);
         return $name;
     } catch (\Zend\Queue\Exception\ExceptionInterface $e) {
         throw new Exception\RuntimeException('Error on queue creation: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
コード例 #2
0
ファイル: ZF-7650Test.php プロジェクト: robertodormepoco/zf2
 public function testActivemqAdapterShouldReturnNoMessagesWhenZeroCountRequested()
 {
     if (!constant('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED')) {
         $this->markTestSkipped('Zend_Queue ActiveMQ adapter tests are not enabled');
     }
     $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 Queue\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));
 }