AppserverIo\Appserver\MessageQueue\QueueWorker::injectManagerSettings PHP Method

injectManagerSettings() public method

Injects the queue manager settings.
public injectManagerSettings ( AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface $managerSettings ) : void
$managerSettings AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface The queue manager settings
return void
    public function injectManagerSettings(QueueManagerSettingsInterface $managerSettings)
    {
        $this->managerSettings = $managerSettings;
    }

Usage Example

Example #1
0
 /**
  * This method will be invoked before the while() loop starts and can be used
  * to implement some bootstrap functionality.
  *
  * @return void
  */
 public function bootstrap()
 {
     // register the default autoloader
     require SERVER_AUTOLOADER;
     // synchronize the application instance and register the class loaders
     $application = $this->application;
     $application->registerClassLoaders();
     // create a reference to the workers/messages
     $workers = $this->workers;
     $messages = $this->messages;
     $managerSettings = $this->managerSettings;
     // try to load the profile logger
     if ($this->profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) {
         $this->profileLogger->appendThreadContext(sprintf('message-queue-%s', $this->getName()));
     }
     // prepare the storages
     $jobsToExceute = array();
     // initialize the counter for the storages
     $counter = 0;
     // create a separate queue for each priority
     foreach (PriorityKeys::getAll() as $priorityKey) {
         // create the containers for the worker
         $jobsToExceute[$counter] = new GenericStackable();
         // initialize and start the queue worker
         $queueWorker = new QueueWorker();
         $queueWorker->injectMessages($messages);
         $queueWorker->injectApplication($application);
         $queueWorker->injectPriorityKey($priorityKey);
         $queueWorker->injectManagerSettings($managerSettings);
         // attach the storages
         $queueWorker->injectJobsToExecute($jobsToExceute[$counter]);
         // start the worker instance
         $queueWorker->start();
         // add the queue instance to the module
         $workers[$this->uniqueWorkerName($priorityKey)] = $queueWorker;
         // raise the counter
         $counter++;
     }
 }