Exemplo n.º 1
0
 public function testDelete()
 {
     $manager = new QueueManager();
     $manager->setClient($this->client);
     $manager->setLogger($this->logger);
     $this->logger->expects($this->once())->method('info')->with('Delete queue <info>qTest</info> from vhost <info>test</info>');
     $this->client->expects($this->once())->method('query')->with(ClientInterface::METHOD_DELETE, '/api/queues/test/qTest')->willReturn(true);
     $this->assertEquals(true, $manager->delete('test', 'qTest'));
 }
Exemplo n.º 2
0
 /**
  * Delete selected queues.
  * If queues == "*" get list of queue from rabbitmq API
  *
  * @param $vhost
  * @param $queues
  */
 public function deleteQueues($vhost, $queues)
 {
     if ('*' === $queues) {
         //so you want to destroy all queues, as you whish, let me time to list' em all
         $queues = $this->queueManager->getAll(urlencode($vhost));
     } elseif (!$vhost) {
         throw new \InvalidArgumentException('If you want to delete certain queue(s) you have to provide vhost');
     } else {
         //few queues to delete, let stack them in array
         $queues = explode(',', $queues);
         array_walk($queues, function (&$item, $key, $vhost) {
             $item = ['vhost' => $vhost, 'name' => trim($item)];
         }, $vhost);
     }
     if (0 == count($queues)) {
         $this->logger->error('No queue found.');
         return;
     }
     foreach ($queues as $queue) {
         $this->queueManager->delete(urlencode($queue['vhost']), $queue['name']);
     }
 }