PHP Class AppserverIo\Appserver\MessageQueue\QueueWorker

Inheritance: extends AppserverIo\Appserver\Core\AbstractDaemonThread
Afficher le fichier Open project: appserver-io/appserver Class Usage Examples

Méthodes publiques

Méthode Description
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.

Method Details

attach() public méthode

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
Résultat void

bootstrap() public méthode

This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality.
public bootstrap ( ) : void
Résultat void

getApplication() public méthode

Returns the application instance the worker is bound to.
public getApplication ( ) : AppserverIo\Psr\Application\ApplicationInterface
Résultat AppserverIo\Psr\Application\ApplicationInterface The application instance

getManagerSettings() public méthode

Return's the queue manager settings.
public getManagerSettings ( ) : AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface
Résultat AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface The queue manager settings

getQueueTimeout() public méthode

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
See also: AppserverIo\Appserver\Core\AbstractDaemonThread::getDefaultTimeout()
public getQueueTimeout ( ) : integer
Résultat integer The default timeout in microseconds

injectApplication() public méthode

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
Résultat void

injectJobsToExecute() public méthode

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
Résultat void

injectManagerSettings() public méthode

Injects the queue manager settings.
public injectManagerSettings ( AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface $managerSettings ) : void
$managerSettings AppserverIo\Appserver\MessageQueue\QueueManagerSettingsInterface The queue manager settings
Résultat void

injectMessages() public méthode

Inject the storage for the messages.
public injectMessages ( AppserverIo\Storage\GenericStackable $messages ) : void
$messages AppserverIo\Storage\GenericStackable The storage for the messages
Résultat void

injectPriorityKey() public méthode

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
Résultat void

log() public méthode

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
Résultat void

run() public méthode

We process the messages/jobs here.
public run ( ) : void
Résultat void