This extension is a Yii2 Queue driver for queues based on Microsoft Azure Service Bus.
It uses the Azure Service Bus REST API
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"
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,
'queue' => 'default', // Optional
'queues' => [
'default' => [ // name of the 'queue' attribute
'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 Azure Service Bus queue (can be different than the name used as config key)',
],
],
],
],
];
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',
]));