yii2-queue
yii2-queue copied to clipboard
How to create a queue programmatically?
How to create multiple queues dynamically? Thanks
please elaborate.
For example we can create 2 queues like this:
config
return [
'components' => [
'queue_search' => [
'class' => Queue::class,
'queueName' => 'queue_search',
'exchangeName' => 'exchange_search',
],
'queue_test1' => [
'class' => Queue::class,
'queueName' => 'queue_test1',
'exchangeName' => 'exchange_test1',
],
],
];
But how to create queue_test1 dynamically without config? Sorry for my english
Excuse me, why do you need this?
You can create queue as is any object, for example:
$queueTest1 = new \yii\queue\amqp\Queue([
'queueName' => 'queue_test1',
'exchangeName' => 'exchange_test1',
]);
$queueTest1->push(/*...*/);
But in this case you have to consider how you will control job execution, because native command will not be registered with the queue object.
How to start worker for this queue object?
Create own console command.