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++;
}
}