AppserverIo\Appserver\MessageQueue\MessageQueue::injectName PHP Method

injectName() public method

Initializes the queue with the name to use.
public injectName ( string $name ) : void
$name string Holds the queue name to use
return void
    public function injectName($name)
    {
        $this->name = $name;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Deploys the message queue described by the passed node.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\MessageQueueNodeInterface $messageQueueNode The node that describes the message queue
  *
  * @return void
  */
 protected function registeMessageQueue(MessageQueueNodeInterface $messageQueueNode)
 {
     // load destination queue and receiver type
     $type = $messageQueueNode->getType();
     $destination = $messageQueueNode->getDestination()->__toString();
     // 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->injectManagerSettings($this->managerSettings);
     $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()->getUniqueName(), $path[$i]));
         } catch (NamingException $ne) {
             $this->directories[$i + 1] = $this->directories[$i]->createSubdirectory(sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), $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()->getUniqueName(), $destination), array(&$this, 'createSenderForQueue'), array($destination));
 }