Пример #1
1
 public function testCreateQueue()
 {
     $queueName = 'test_queue';
     $db = DriverManager::getConnection(['driver' => 'pdo_mysql', 'host' => SYRUP_DATABASE_HOST, 'dbname' => SYRUP_DATABASE_NAME, 'user' => SYRUP_DATABASE_USER, 'password' => SYRUP_DATABASE_PASSWORD, 'port' => SYRUP_DATABASE_PORT]);
     $db->query("DELETE FROM queues WHERE id='{$queueName}'")->execute();
     $command = $this->application->find('syrup:queue:create');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['name' => $queueName, '--register' => null, '--no-watch' => null]);
     $this->assertEquals(0, $commandTester->getStatusCode());
     $factory = new QueueFactory($db, ['db_table' => 'queues'], SYRUP_APP_NAME);
     $dbQueue = $factory->get($queueName);
     $queueUrlArr = explode('/', $dbQueue->getUrl());
     $this->assertEquals($queueName, array_pop($queueUrlArr));
     $sqsClient = new SqsClient(['version' => '2012-11-05', 'region' => 'us-east-1']);
     $sqsClient->deleteQueue(['QueueUrl' => $dbQueue->getUrl()]);
 }
Пример #2
0
 public function testCreate()
 {
     $db = DriverManager::getConnection(['driver' => 'pdo_mysql', 'host' => SYRUP_DATABASE_HOST, 'dbname' => SYRUP_DATABASE_NAME, 'user' => SYRUP_DATABASE_USER, 'password' => SYRUP_DATABASE_PASSWORD, 'port' => SYRUP_DATABASE_PORT]);
     $factory = new QueueFactory($db, ['db_table' => 'queues'], SYRUP_APP_NAME);
     $sqsQueue = $factory->create('test');
     $queueUrlArr = explode('/', $sqsQueue->get('QueueUrl'));
     $this->assertEquals('test', array_pop($queueUrlArr));
     // delete the queue from AWS
     $sqsClient = new SqsClient(['version' => '2012-11-05', 'region' => 'us-east-1']);
     $sqsClient->deleteQueue(['QueueUrl' => $sqsQueue->get('QueueUrl')]);
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function remove(QueueAdapterInterface $queue)
 {
     if (!$queue instanceof SqsQueue) {
         throw new InvalidArgumentException('expecting an instance of SqsQueue');
     }
     try {
         $this->client->deleteQueue(['QueueUrl' => $queue->getUrl()]);
     } catch (\Exception $ex) {
         throw new RuntimeException($ex->getMessage(), $ex->getCode(), $ex);
     }
 }
Пример #4
0
 /**
  * @inheritdoc
  *
  * @throws SqsException
  */
 public function deleteQueue($queueName)
 {
     if (empty($queueName)) {
         throw new InvalidArgumentException('Parameter queueName empty or not defined.');
     }
     $priorities = $this->priorityHandler->getAll();
     foreach ($priorities as $priority) {
         $queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
         $this->sqsClient->deleteQueue(['QueueUrl' => $queueUrl]);
     }
     return $this;
 }
Пример #5
0
 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  * @throws QueueAccessException
  */
 public function deleteQueue($queueName)
 {
     if (empty($queueName)) {
         throw new \InvalidArgumentException('Queue name empty or not defined.');
     }
     $priorities = $this->priorityHandler->getAll();
     foreach ($priorities as $priority) {
         try {
             $queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
             $this->sqsClient->deleteQueue(['QueueUrl' => $queueUrl]);
         } catch (SqsException $e) {
             throw new QueueAccessException('Cannot delete queue.', 0, $e);
         }
     }
     return $this;
 }
Пример #6
0
 /**
  * @return Boolean
  */
 public function destroy()
 {
     $key = $this->getNameWithPrefix() . '_url';
     $this->cache->delete($key);
     if ($this->queueExists()) {
         // Delete the SQS Queue
         $this->sqs->deleteQueue(['QueueUrl' => $this->queueUrl]);
         $this->log(200, "SQS Queue removed", ['QueueUrl' => $this->queueUrl]);
     }
     $key = $this->getNameWithPrefix() . '_arn';
     $this->cache->delete($key);
     if ($this->topicExists() || !empty($this->queueUrl)) {
         // Delete the SNS Topic
         $topicArn = !empty($this->topicArn) ? $this->topicArn : str_replace('sqs', 'sns', $this->queueUrl);
         $this->sns->deleteTopic(['TopicArn' => $topicArn]);
         $this->log(200, "SNS Topic removed", ['TopicArn' => $topicArn]);
     }
     return true;
 }
Пример #7
0
 /**
  * {@inheritDoc}
  */
 public function deleteQueue($queueId = null)
 {
     $queueUrl = $this->getQueueUrl($queueId);
     $this->queueClient->deleteQueue(["QueueUrl" => $queueUrl]);
 }
Пример #8
0
 public function deleteQueue()
 {
     $args = ["QueueUrl" => $this->getQueueUrl()];
     $this->client->deleteQueue($args);
 }