/akkastream-azure

Akka Stream connector for Azure Storage Queue

Primary LanguageScalaApache License 2.0Apache-2.0

Moved into alpakka.


akkazure

Build Status

akkazure is an Akka Stream connector for the Azure Queue Storage.

Example usage

Init Azure Storage API

import com.microsoft.azure.storage._
import com.microsoft.azure.storage.queue._
val storageConnectionString = "DefaultEndpointsProtocol=http;AccountName=<YourAccountName>;AccountKey=<YourKey>"
val storageAccount = CloudStorageAccount.parse(storageConnectionString)
val queueClient = storageAccount.createCloudQueueClient
val queue = queueClient.getQueueReference("myQueue")

For more details, see Microsoft Azure Storage Docs.

Queuing a message

import one.aleph.akkzure.queue._
import one.aleph.akkzure.queue.scaladsl._

// Create an example message
val message = new CloudQueueMessage("Hello Azure")

Source.single(message).runWith(AzureQueueSink(queue)

Processing and deleting messages

AzureQueueSource(queue).take(10)
.map({ msg: CloudQueueMessage =>  
  println(msg.getMessageContentAsString) // Print the messages content
  msg                                    // Return message to the flow for deletion
}).runWith(AzureQueueDeleteSink(queue))