Azure Storage Queue
The Azure Storage Queue connector provides an Apache Pekko Stream Source and Sinks for Azure Storage Queue integration.
Azure Storage Queue is a queuing service similar to Amazon’s SQS. It is designed mostly for long-running and non-time-critical tasks. For more information on Azure Storage Queue see the Azure docs.
| Project Info: Apache Pekko Connectors Azure Storage Queue | |
|---|---|
| Artifact | org.apache.pekko
pekko-connectors-azure-storage-queue
2.0.0-RC1
|
| JDK versions | OpenJDK 17 OpenJDK 21 |
| Scala versions | 2.13.18, 3.3.9 |
| JPMS module name | pekko.stream.connectors.azure.storagequeue |
| License | |
| API documentation | |
| Forums | |
| Release notes | GitHub releases |
| Issues | Github issues |
| Sources | https://github.com/apache/pekko-connectors |
Artifacts
- sbt
val PekkoVersion = "2.0.0" libraryDependencies ++= Seq( "org.apache.pekko" %% "pekko-connectors-azure-storage-queue" % "2.0.0-RC1", "org.apache.pekko" %% "pekko-stream" % PekkoVersion )- Maven
<properties> <pekko.version>2.0.0</pekko.version> <scala.binary.version>2.13</scala.binary.version> </properties> <dependencies> <dependency> <groupId>org.apache.pekko</groupId> <artifactId>pekko-connectors-azure-storage-queue_${scala.binary.version}</artifactId> <version>2.0.0-RC1</version> </dependency> <dependency> <groupId>org.apache.pekko</groupId> <artifactId>pekko-stream_${scala.binary.version}</artifactId> <version>${pekko.version}</version> </dependency> </dependencies>- Gradle
def versions = [ PekkoVersion: "2.0.0", ScalaBinary: "2.13" ] dependencies { implementation "org.apache.pekko:pekko-connectors-azure-storage-queue_${versions.ScalaBinary}:2.0.0-RC1" implementation "org.apache.pekko:pekko-stream_${versions.ScalaBinary}:${versions.PekkoVersion}" }
The table below shows direct dependencies of this module and the second tab shows all libraries it depends on transitively.
- Direct dependencies
Organization Artifact Version com.microsoft.azure azure-storage 8.6.6 org.apache.pekko pekko-stream_2.13 2.0.0 org.scala-lang scala-library 2.13.18 - Dependency tree
com.microsoft.azure azure-storage 8.6.6 The Apache Software License, Version 2.0 com.fasterxml.jackson.core jackson-core 2.9.4 The Apache Software License, Version 2.0 com.microsoft.azure azure-keyvault-core 1.2.4 The MIT License (MIT) com.google.guava guava 24.1.1-jre The Apache Software License, Version 2.0 com.google.code.findbugs jsr305 1.3.9 The Apache Software License, Version 2.0 com.google.errorprone error_prone_annotations 2.1.3 Apache 2.0 com.google.j2objc j2objc-annotations 1.1 The Apache Software License, Version 2.0 org.checkerframework checker-compat-qual 2.0.0 GNU General Public License, version 2 (GPL2), with the classpath exception org.codehaus.mojo animal-sniffer-annotations 1.14 MIT license org.apache.commons commons-lang3 3.8.1 Apache License, Version 2.0 org.apache.commons commons-lang3 3.8.1 Apache License, Version 2.0 org.slf4j slf4j-api 1.7.12 MIT License org.apache.pekko pekko-stream_2.13 2.0.0 Apache-2.0 org.apache.pekko pekko-actor_2.13 2.0.0 Apache-2.0 com.typesafe config 1.4.9 Apache-2.0 org.scala-lang scala-library 2.13.18 Apache-2.0 org.apache.pekko pekko-protobuf-v3_2.13 2.0.0 Apache-2.0 org.reactivestreams reactive-streams 1.0.4 MIT-0 org.scala-lang scala-library 2.13.18 Apache-2.0 org.scala-lang scala-library 2.13.18 Apache-2.0
Init Azure Storage API
import com.microsoft.azure.storage._
import com.microsoft.azure.storage.queue._
val storageConnectionString = "DefaultEndpointsProtocol=http;AccountName=<YourAccountName>;AccountKey=<YourKey>"
val queueFactory = () => { // Since azure storage JDK is not guaranteed to be thread-safe
val storageAccount = CloudStorageAccount.parse(storageConnectionString)
val queueClient = storageAccount.createCloudQueueClient
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(queueFactory))
Processing and deleting messages
AzureQueueSource(queueFactory).take(10)
.map({ msg: CloudQueueMessage =>
println(msg.getMessageContentAsString) // Print the messages content
msg // Return message to the flow for deletion
}).runWith(AzureQueueDeleteSink(queueFactory))
2.0.0-RC1