Example #1
0
 /**
  * Deploys the message queue described by the passed XML node.
  *
  * @param \SimpleXMLElement $node The XML node that describes the message queue
  *
  * @return void
  */
 protected function registeMessageQueue(\SimpleXMLElement $node)
 {
     // load the nodes attributes
     $attributes = $node->attributes();
     // load destination queue and receiver type
     $destination = (string) $node->destination;
     $type = (string) $attributes['type'];
     // initialize the message queue
     $messageQueue = new MessageQueue();
     $messageQueue->injectType($type);
     $messageQueue->injectName($destination);
     $messageQueue->injectWorkers($this->workers);
     $messageQueue->injectMessages($this->messages);
     $messageQueue->injectApplication($this->application);
     $messageQueue->injectQueueSettings($this->queueSettings);
     $messageQueue->start();
     // initialize the queues storage for the priorities
     $this->queues[$messageQueue->getName()] = $messageQueue;
     // prepare the naming directory to bind the callback to
     $path = explode('/', $destination);
     for ($i = 0; $i < sizeof($path) - 1; $i++) {
         try {
             $this->directories[$i]->search(sprintf('php:global/%s/%s', $this->getApplication()->getName(), $path[$i]));
         } catch (NamingException $ne) {
             $this->directories[$i + 1] = $this->directories[$i]->createSubdirectory(sprintf('php:global/%s/%s', $this->getApplication()->getName(), $path[$i]));
         }
     }
     // bind the callback for creating a new MQ sender instance to the naming directory => necessary for DI provider
     $this->getApplication()->getNamingDirectory()->bindCallback(sprintf('php:global/%s/%s', $this->getApplication()->getName(), $destination), array(&$this, 'createSenderForQueue'), array($destination));
 }