PHP code example of oat-sa / extension-tao-task-queue
1. Go to this page and download the library: Download oat-sa/extension-tao-task-queue library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oat-sa / extension-tao-task-queue example snippets
use oat\tao\model\taskQueue\QueueDispatcher;
use oat\tao\model\taskQueue\Queue;
use oat\taoTaskQueue\model\QueueBroker\RdsQueueBroker;
use oat\taoTaskQueue\model\QueueBroker\SqsQueueBroker;
use oat\tao\model\taskQueue\TaskLogInterface;
use oat\tao\model\taskQueue\QueueDispatcherInterface;
$queueService = new QueueDispatcher(array(
QueueDispatcherInterface::OPTION_QUEUES => [
new Queue('priority', new SqsQueueBroker('default', \common_cache_Cache::SERVICE_ID, 10), 90),
new Queue('standard', new RdsQueueBroker('default', 5), 30),
new Queue('background', new RdsQueueBroker('default', 5), 10)
],
QueueDispatcherInterface::OPTION_TASK_LOG => TaskLogInterface::SERVICE_ID,
QueueDispatcherInterface::OPTION_TASK_TO_QUEUE_ASSOCIATIONS => [
SomeImportantAction::class => 'priority',
SomeLessImportantTask::class => 'standard'
]
));
$queueService->setOption(QueueDispatcherInterface::OPTION_DEFAULT_QUEUE, 'background');
$this->getServiceManager()->register(QueueDispatcherInterface::SERVICE_ID, $queueService);