https://github.com/zio/zio-sqs
ZIO-powered client for AWS SQS
https://github.com/zio/zio-sqs
aws-sdk connector functional-programming scala sqs stream zio
Last synced: 18 days ago
JSON representation
ZIO-powered client for AWS SQS
- Host: GitHub
- URL: https://github.com/zio/zio-sqs
- Owner: zio
- License: apache-2.0
- Created: 2019-05-01T09:30:45.000Z (almost 6 years ago)
- Default Branch: series/2.x
- Last Pushed: 2025-03-23T13:25:36.000Z (about 1 month ago)
- Last Synced: 2025-03-29T13:06:23.123Z (25 days ago)
- Topics: aws-sdk, connector, functional-programming, scala, sqs, stream, zio
- Language: Scala
- Homepage: https://zio.dev/zio-sqs
- Size: 534 KB
- Stars: 84
- Watchers: 4
- Forks: 27
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-zio - ZIO SQS - powered client for AWS SQS (Official ZIO Libraries)
README
[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)
[//]: # (So please do not edit it manually. Instead, change "docs/index.md" file or sbt setting keys)
[//]: # (e.g. "readmeDocumentation" and "readmeSupport".)# ZIO SQS
[ZIO SQS](https://zio.dev/zio-sqs) is a ZIO-powered client for AWS SQS. It is built on top of the [AWS SDK for Java 2.0](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/basics.html) via the automatically generated wrappers from [zio-aws](https://zio.dev/zio-aws).
[](https://github.com/zio/zio/wiki/Project-Stages)  [](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sqs_2.13/) [](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sqs_2.13/) [](https://javadoc.io/doc/dev.zio/zio-sqs-docs_2.13) [](https://github.com/zio/zio-sqs)
## Introduction
ZIO SQS enables us to produce and consume elements to/from the Amazon SQS service. It is integrated with ZIO Streams, so we can produce and consume elements in a streaming fashion, element by element or micro-batching.
## Installation
In order to use this library, we need to add the following line in our `build.sbt` file:
```scala
libraryDependencies += "dev.zio" %% "zio-sqs" % "0.7.3"
```## Example
In this example we produce a stream of events to the `MyQueue` and then consume them from that queue (at-most-once delivery semantics):
```scala
import zio._
import zio.aws.core.config.AwsConfig
import zio.aws.netty.NettyHttpClient
import zio.aws.sqs.Sqs
import zio.sqs.producer.{Producer, ProducerEvent}
import zio.sqs.serialization.Serializer
import zio.sqs.{SqsStream, SqsStreamSettings, Utils}
import zio.stream.ZStreamobject ProducerConsumerExample extends ZIOAppDefault {
val queueName = "MyQueue"val stream: ZStream[Any, Nothing, ProducerEvent[String]] =
ZStream.iterate(0)(_ + 1).map(_.toString).map(ProducerEvent(_))val program: ZIO[Sqs, Throwable, Unit] = for {
_ <- Utils.createQueue(queueName)
queueUrl <- Utils.getQueueUrl(queueName)
producer = Producer.make(queueUrl, Serializer.serializeString)
_ <- ZIO.scoped(producer.flatMap(_.sendStream(stream).runDrain))
_ <- SqsStream(
queueUrl,
SqsStreamSettings.default
.withAutoDelete(true)
.withStopWhenQueueEmpty(true)
.withWaitTimeSeconds(3)
).foreach(msg => Console.printLine(msg.body))
} yield ()def run =
program.provide(
Sqs.live,
AwsConfig.default,
NettyHttpClient.default
)
}
```Check out the examples folder in `zio-sqs/src/test/scala/examples` for additional examples that cover at-least-once and at-most-once delivery semantics.
## Documentation
Learn more on the [ZIO SQS homepage](https://zio.dev/zio-sqs)!
## Contributing
For the general guidelines, see ZIO [contributor's guide](https://zio.dev/contributor-guidelines).
## Code of Conduct
See the [Code of Conduct](https://zio.dev/code-of-conduct)
## Support
Come chat with us on [![Badge-Discord]][Link-Discord].
[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord "chat on discord"
[Link-Discord]: https://discord.gg/2ccFBr4 "Discord"## License
[License](LICENSE)