PHP Класс AppserverIo\Appserver\MessageQueue\QueueWorker

Автор: Tim Wagner ([email protected])
Наследование: extends AppserverIo\Appserver\Core\AbstractDaemonThread
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
attach ( stdClass $jobWrapper ) : void Attaches a job for the passed wrapper to the worker instance.
bootstrap ( ) : void This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality.
getApplication ( ) : AppserverIo\Psr\Application\ApplicationInterface Returns the application instance the worker is bound to.
getManagerSettings ( ) : AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface Return's the queue manager settings.
getQueueTimeout ( ) : integer Returns the default timeout.
injectApplication ( AppserverIo\Psr\Application\ApplicationInterface $application ) : void Inject the application instance the worker is bound to.
injectJobsToExecute ( AppserverIo\Storage\GenericStackable $jobsToExecute ) : void Inject the storage for the jobs to be executed.
injectManagerSettings ( AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface $managerSettings ) : void Injects the queue manager settings.
injectMessages ( AppserverIo\Storage\GenericStackable $messages ) : void Inject the storage for the messages.
injectPriorityKey ( AppserverIo\Psr\Pms\PriorityKeyInterface $priorityKey ) : void Injects the priority of the queue worker.
log ( mixed $level, string $message, array $context = [] ) : void This is a very basic method to log some stuff by using the error_log() method of PHP.
run ( ) : void We process the messages/jobs here.

Описание методов

attach() публичный метод

Attaches a job for the passed wrapper to the worker instance.
public attach ( stdClass $jobWrapper ) : void
$jobWrapper stdClass The job wrapper to attach the job for
Результат void

bootstrap() публичный метод

This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality.
public bootstrap ( ) : void
Результат void

getApplication() публичный метод

Returns the application instance the worker is bound to.
public getApplication ( ) : AppserverIo\Psr\Application\ApplicationInterface
Результат AppserverIo\Psr\Application\ApplicationInterface The application instance

getManagerSettings() публичный метод

Return's the queue manager settings.
public getManagerSettings ( ) : AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface
Результат AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface The queue manager settings

getQueueTimeout() публичный метод

Reduce CPU load depending on the queues priority, whereas priority can be 1, 2 or 3 actually, so possible values for usleep are: PriorityHigh: 100 === 0.0001 s PriorityMedium: 10.000 === 0.01 s PriorityLow: 1.000.000 === 1 s
См. также: AppserverIo\Appserver\Core\AbstractDaemonThread::getDefaultTimeout()
public getQueueTimeout ( ) : integer
Результат integer The default timeout in microseconds

injectApplication() публичный метод

Inject the application instance the worker is bound to.
public injectApplication ( AppserverIo\Psr\Application\ApplicationInterface $application ) : void
$application AppserverIo\Psr\Application\ApplicationInterface The application instance
Результат void

injectJobsToExecute() публичный метод

Inject the storage for the jobs to be executed.
public injectJobsToExecute ( AppserverIo\Storage\GenericStackable $jobsToExecute ) : void
$jobsToExecute AppserverIo\Storage\GenericStackable The storage for the jobs to be executed
Результат void

injectManagerSettings() публичный метод

Injects the queue manager settings.
public injectManagerSettings ( AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface $managerSettings ) : void
$managerSettings AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface The queue manager settings
Результат void

injectMessages() публичный метод

Inject the storage for the messages.
public injectMessages ( AppserverIo\Storage\GenericStackable $messages ) : void
$messages AppserverIo\Storage\GenericStackable The storage for the messages
Результат void

injectPriorityKey() публичный метод

Injects the priority of the queue worker.
public injectPriorityKey ( AppserverIo\Psr\Pms\PriorityKeyInterface $priorityKey ) : void
$priorityKey AppserverIo\Psr\Pms\PriorityKeyInterface The priority of this queue worker
Результат void

log() публичный метод

This is a very basic method to log some stuff by using the error_log() method of PHP.
public log ( mixed $level, string $message, array $context = [] ) : void
$level mixed The log level to use
$message string The message we want to log
$context array The context we of the message
Результат void

run() публичный метод

We process the messages/jobs here.
public run ( ) : void
Результат void