Esempio n. 1
0
 /**
  * The CreateQueue action creates a new queue.
  *
  * When you request CreateQueue, you provide a name for the queue.
  * To successfully create a new queue, you must provide a name that is unique within the scope of your own queues.
  *
  * Note! If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.
  *
  * If you provide the name of an existing queue, along with the exact names and values of all the queue's
  * attributes, CreateQueue returns the queue URL for the existing queue. If the queue name, attribute
  * names, or attribute values do not match an existing queue, CreateQueue returns an error.
  *
  * @param   string             $queueName           A Queue name
  * @param   QueueAttributeList $queueAttributeList  optional QueueAttributeList
  * @return  QueueData          Returns QueueData
  * @throws  ClientException
  * @throws  SqsException
  */
 public function createQueue($queueName, QueueAttributeList $queueAttributeList = null)
 {
     $result = null;
     $options = array('QueueName' => (string) $queueName);
     if ($queueAttributeList !== null) {
         $options = array_merge($options, $queueAttributeList->getQueryArrayBare('Attribute'));
     }
     $response = $this->client->call('CreateQueue', $options, '/');
     if ($response->getError() === false) {
         //Success
         $sxml = simplexml_load_string($response->getRawContent());
         if (!isset($sxml->CreateQueueResult->QueueUrl)) {
             throw new SqsException('Unexpected response! ' . $response->getRawContent());
         }
         $queueUrl = (string) $sxml->CreateQueueResult->QueueUrl;
         if (($result = $this->sqs->queue->get($options['QueueName'])) !== null) {
             //This just updates queueUrl if queue already exists.
             $result->queueUrl = $queueUrl;
         } else {
             $em = $this->getEntityManager();
             $result = new QueueData();
             $result->setSqs($this->sqs);
             $result->queueName = $options['QueueName'];
             $result->queueUrl = $queueUrl;
             $em->attach($result);
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * The GetQueueAttributes action fetches all attributes of a queue.
  *
  * @param   string             $queueName          The queue name.
  * @param   array|ListDataType $queueAttributeList optional The attribute list you want to get.
  * @return  QueueAttributeList  Returns QueueAttributeList
  * @throws  ClientException
  * @throws  SqsException
  */
 public function fetchAttributes()
 {
     $attributes = new QueueAttributeList();
     //Fetches attributes and stores its values directly to this object.
     $this->getSqs()->queue->getAttributes($this->queueName, null);
     foreach (QueueAttributeData::getAvailableAttributes() as $attr) {
         $getfn = 'get' . $attr;
         $attributes->append(new QueueAttributeData($attr, $this->{$getfn}()));
     }
     return $attributes;
 }