sagacorp/yii2-queue-azure-service-bus

Yii2 Queue driver for Azure service bus

1.2.0 2022-11-25 16:22 UTC

This package is auto-updated.

Last update: 2024-04-08 16:34:16 UTC


README

This extension is a Yii2 Queue driver for queues based on Microsoft Azure Service Bus.

It uses the Azure Service Bus REST API

Installation

Install this extension with composer.

Either run

php composer.phar require --prefer-dist sagacorp/yii2-queue-azure-service-bus

or add the extension to your composer json.

"sagacorp/yii2-queue-azure-service-bus": "~1.0.0"

Basic Usage

First, you may configure your Azure service Bus.

Then, configure yii2 queue, and the service bus like the following:

return [
    'components' => [
        'queue'                   => [
            'class'      => \saga\queue\azure\Queue::class,
            'as log'     => \yii\queue\LogBehavior,
            'serializer' => \yii\queue\serializers\JsonSerializer::class,
        ],
        'serviceBus'              => [
            'class'               => \saga\queue\azure\service\ServiceBus::class,
            'serviceBusNamespace' => 'your service bus namespace',
            'sharedAccessKey'     => 'your shared access key to access the service bus queue',
            'sharedAccessKeyName' => 'your shared access key name',
            'queue'               => 'the name of your Aruez Service Bus queue',
        ],
    ]
];

Currently this extension supports the Shared Access Signature authentication only. It doesn't support Azure Active Directory.

Once configured, you can send a task into the queue:

Yii::$app->queue->push(new DownloadJob([
    'url' => 'http://example.com/image.jpg',
    'file' => '/tmp/image.jpg',
]));