Пример #1
0
 /**
  * List all queues.
  *
  * @param  array $options
  * @return array Queue IDs
  */
 public function listQueues($options = null)
 {
     try {
         return $this->_queue->getQueues();
     } catch (\Zend\Queue\Exception $e) {
         throw new Exception\RuntimeException('Error on listing queues: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
Пример #2
0
 /**
  * Send a message to the queue
  *
  * @param  \ZendTest\Queue\Custom\Message|\ZendTest\Queue\Custom\Messages $message message
  * @return $this
  * @throws Zend_Queue_Exception
  */
 public function send($message)
 {
     if (!($message instanceof Message || $message instanceof Messages)) {
         throw new \Zend\Queue\Exception('$message must be an instance of \\ZendTest\\Queue\\Custom\\Message or \\ZendTest\\Queue\\Custom\\Messages');
     }
     if ($message instanceof Message) {
         $response = parent::send($message->__toString());
     } else {
         foreach ($message as $i => $one) {
             $response = parent::send($one->__toString());
         }
     }
     return $this;
 }
Пример #3
0
 /**
  * Subscribes the client to the queue.
  *
  * @param  \Zend\Queue\Queue $queue
  * @return void
  */
 protected function subscribe(Queue\Queue $queue)
 {
     $frame = $this->_client->createFrame();
     $frame->setCommand('SUBSCRIBE');
     $frame->setHeader('destination', $queue->getName());
     $frame->setHeader('ack','client');
     $this->_client->send($frame);
     $this->_subscribed[$queue->getName()] = TRUE;
 }
Пример #4
0
 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));
 }