Message Queue Azure Storage Transport

Message Queue Azure Storage Transport

README

assoConnect logo

Azure Storage transport

Azure Storage transport is a messaging solution transport using Azure comptabile with Queue Interop

Build Status

Azure Storage transport

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

  • With composer:
$ composer require assoconnect/enqueue-azure

Create context

<?php
use EnqueueAzureStorageAzureStorageConnectionFactory;

// connects to azure
$factory = new AzureStorageConnectionFactory('DefaultEndpointsProtocol=https;AccountName=<accountname>;AccountKey=<youraccountkey>');

$context = $factory->createContext();

Send message to topic

<?php
/** @var EnqueueAzureStorageAzureStorageContext $context */

$fooTopic = $context->createTopic('aTopic');
$message = $context->createMessage('Hello world!');

$context->createProducer()->send($fooTopic, $message);

Send message to queue

<?php
/** @var EnqueueAzureStorageAzureStorageContext $context */

$fooQueue = $context->createQueue('aQueue');
$message = $context->createMessage('Hello world!');

$context->createProducer()->send($fooQueue, $message);

Send expiration message

<?php
/** @var EnqueueAzureStorageAzureStorageContext $context */
/** @var EnqueueAzureStorageAzureStorageDestination $fooQueue */


$message = $context->createMessage('Hello world!');

$context->createProducer()
    ->setTimeToLive(60000) // 60 sec
    ->send($fooQueue, $message)
;

Consume message:

<?php
/** @var EnqueueAzureStorageAzureStorageContext $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 EnqueueAzureStorageAzureStorageContext $context */

$fooQueue = $context->createQueue('aQueue');

$context->deleteQueue($fooQueue);

Delete topic (purge messages):

<?php
/** @var EnqueueAzureStorageAzureStorageContext $context */

$fooTopic = $context->createTopic('aTopic');

$context->deleteTopic($fooTopic);

back to index

Source

Add a Comment

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *