Azure Storage transport is a messaging solution transport using Azure comptabile with Queue Interop
The transport uses Azure Storage as a message broker. It creates a collection (a queue or topic) there. It's a FIFO system (First In First Out).
- Installation
- Create context
- Send message to topic
- Send message to queue
- Send expiration message
- Consume message
- Delete queue (purge messages)
- Delete topic (purge messages)
- With composer:
$ composer require assoconnect/enqueue-azure
<?php
use Enqueue\AzureStorage\AzureStorageConnectionFactory;
// connects to azure
$factory = new AzureStorageConnectionFactory('DefaultEndpointsProtocol=https;AccountName=<accountname>;AccountKey=<youraccountkey>');
$context = $factory->createContext();
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
$fooTopic = $context->createTopic('aTopic');
$message = $context->createMessage('Hello world!');
$context->createProducer()->send($fooTopic, $message);
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
$fooQueue = $context->createQueue('aQueue');
$message = $context->createMessage('Hello world!');
$context->createProducer()->send($fooQueue, $message);
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
/** @var \Enqueue\AzureStorage\AzureStorageDestination $fooQueue */
$message = $context->createMessage('Hello world!');
$context->createProducer()
->setTimeToLive(60000) // 60 sec
->send($fooQueue, $message)
;
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
$fooQueue = $context->createQueue('aQueue');
$consumer = $context->createConsumer($fooQueue);
$message = $consumer->receiveNoWait();
// process a message
$consumer->acknowledge($message);
//$consumer->reject($message);
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
$fooQueue = $context->createQueue('aQueue');
$context->deleteQueue($fooQueue);
<?php
/** @var \Enqueue\AzureStorage\AzureStorageContext $context */
$fooTopic = $context->createTopic('aTopic');
$context->deleteTopic($fooTopic);