assoconnect / enqueue-azure
Message Queue Azure Storage Transport
v1.1.1
2019-11-19 12:14 UTC
Requires
- php: ^7.1.3
- enqueue/enqueue: ^0.9.0@dev
- microsoft/azure-storage-queue: ^1.1
- queue-interop/queue-interop: ^0.7|^0.8
Requires (Dev)
- enqueue/null: 0.9.x-dev
- enqueue/test: 0.9.x-dev
- phpunit/phpunit: ~5.4.0
- queue-interop/queue-spec: 0.6.x-dev
README
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)
Installation
- With composer:
$ composer require assoconnect/enqueue-azure
Create context
<?php use Enqueue\AzureStorage\AzureStorageConnectionFactory; // connects to azure $factory = new AzureStorageConnectionFactory('DefaultEndpointsProtocol=https;AccountName=<accountname>;AccountKey=<youraccountkey>'); $context = $factory->createContext();
Send message to topic
<?php /** @var \Enqueue\AzureStorage\AzureStorageContext $context */ $fooTopic = $context->createTopic('aTopic'); $message = $context->createMessage('Hello world!'); $context->createProducer()->send($fooTopic, $message);
Send message to queue
<?php /** @var \Enqueue\AzureStorage\AzureStorageContext $context */ $fooQueue = $context->createQueue('aQueue'); $message = $context->createMessage('Hello world!'); $context->createProducer()->send($fooQueue, $message);
Send expiration 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) ;
Consume 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);
Delete queue (purge messages):
<?php /** @var \Enqueue\AzureStorage\AzureStorageContext $context */ $fooQueue = $context->createQueue('aQueue'); $context->deleteQueue($fooQueue);
Delete topic (purge messages):
<?php /** @var \Enqueue\AzureStorage\AzureStorageContext $context */ $fooTopic = $context->createTopic('aTopic'); $context->deleteTopic($fooTopic);