PHP Class AppserverIo\Appserver\MessageQueue\QueueWorker

Inheritance: extends AppserverIo\Appserver\Core\AbstractDaemonThread
Show file Open project: appserver-io/appserver Class Usage Examples

Public Methods

Method 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 method

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
return void

bootstrap() public method

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

getApplication() public method

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

getManagerSettings() public method

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

getQueueTimeout() public method

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
return integer The default timeout in microseconds

injectApplication() public method

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
return void

injectJobsToExecute() public method

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
return void

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

injectMessages() public method

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

injectPriorityKey() public method

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
return void

log() public method

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
return void

run() public method

We process the messages/jobs here.
public run ( ) : void
return void