Class QueueManager
Property Summary
Method Summary
-
configured() public static
Get the configured queue keys.
-
drop() public static
Remove a configured queue adapter.
-
engine() public static
Get a queueing engine
-
getConfig() public static
Reads existing configuration.
-
getUniqueId() public static
-
push() public static
Push a single job onto the queue.
-
setConfig() public static
This method can be used to define configuration adapters for an application.
Method Detail
configured() ¶ public static
configured(): array
Get the configured queue keys.
Returns
arrayList of configured queue configuration keys.
drop() ¶ public static
drop(string $key): void
Remove a configured queue adapter.
Parameters
-
string$key The config name to drop.
Returns
voidengine() ¶ public static
engine(string $name): Enqueue\SimpleClient\SimpleClient
Get a queueing engine
Parameters
-
string$name Key name of a configured adapter to get.
Returns
Enqueue\SimpleClient\SimpleClientgetConfig() ¶ public static
getConfig(string $key): mixed
Reads existing configuration.
Parameters
-
string$key The name of the configuration.
Returns
mixedConfiguration data at the named key or null if the key does not exist.
getUniqueId() ¶ public static
getUniqueId(string $class, string $method, array $data): string
Parameters
-
string$class Class name
-
string$method Method name
-
array$data Message data
Returns
stringpush() ¶ public static
push(array<string>|string $className, array $data = [], array $options = []): void
Push a single job onto the queue.
Parameters
-
array<string>|string$className The classname of a job that implements the \Cake\Queue\Job\JobInterface. The class will be constructed by \Cake\Queue\Processor and have the execute method invoked.
-
array$data optional An array of data that will be passed to the job.
-
array$options optional An array of options for publishing the job:
config- A queue config name. Defaults to 'default'.delay- Time (in integer seconds) to delay message, after which it will be processed. Not all message brokers accept this. Defaultnull.expires- Time (in integer seconds) after which the message expires. The message will be removed from the queue if this time is exceeded and it has not been consumed. Defaultnull.priority- Valid values:\Enqueue\Client\MessagePriority::VERY_LOW\Enqueue\Client\MessagePriority::LOW\Enqueue\Client\MessagePriority::NORMAL\Enqueue\Client\MessagePriority::HIGH\Enqueue\Client\MessagePriority::VERY_HIGH
queue- The name of a queue to use, from queueconfigarray or string 'default' if empty.
Returns
voidsetConfig() ¶ public static
setConfig(array|string $key, array $config = null): void
This method can be used to define configuration adapters for an application.
To change an adapter's configuration at runtime, first drop the adapter and then reconfigure it.
Adapters will not be constructed until the first operation is done.
Usage
Assuming that the class' name is QueueManager the following scenarios
are supported:
Setting a queue engine up.
QueueManager::setConfig('default', $settings);
Injecting a constructed adapter in:
QueueManager::setConfig('default', $instance);
Configure multiple adapters at once:
QueueManager::setConfig($arrayOfConfig);
Parameters
-
array|string$key The name of the configuration, or an array of multiple configs.
-
array$config optional An array of name => configuration data for adapter.
Returns
voidThrows
BadMethodCallExceptionWhen trying to modify an existing config.
LogicExceptionWhen trying to store an invalid structured config array.