zio-amqp


License

License

GroupId

GroupId

nl.vroste
ArtifactId

ArtifactId

zio-amqp_2.11
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

zio-amqp
zio-amqp
Project URL

Project URL

https://github.com/svroonland/zio-amqp
Project Organization

Project Organization

nl.vroste
Source Code Management

Source Code Management

https://github.com/svroonland/zio-amqp/

Download zio-amqp_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/nl.vroste/zio-amqp_2.11/ -->
<dependency>
    <groupId>nl.vroste</groupId>
    <artifactId>zio-amqp_2.11</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/nl.vroste/zio-amqp_2.11/
implementation 'nl.vroste:zio-amqp_2.11:0.2.0'
// https://jarcasting.com/artifacts/nl.vroste/zio-amqp_2.11/
implementation ("nl.vroste:zio-amqp_2.11:0.2.0")
'nl.vroste:zio-amqp_2.11:jar:0.2.0'
<dependency org="nl.vroste" name="zio-amqp_2.11" rev="0.2.0">
  <artifact name="zio-amqp_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='nl.vroste', module='zio-amqp_2.11', version='0.2.0')
)
libraryDependencies += "nl.vroste" % "zio-amqp_2.11" % "0.2.0"
[nl.vroste/zio-amqp_2.11 "0.2.0"]

Dependencies

compile (6)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
dev.zio : zio-streams_2.11 jar 1.0.7
dev.zio : zio-interop-reactivestreams_2.11 jar 1.3.3
com.rabbitmq : amqp-client jar 5.12.0
ch.qos.logback : logback-classic jar 1.2.3
org.scala-lang.modules : scala-collection-compat_2.11 jar 2.4.3

test (2)

Group / Artifact Type Version
dev.zio : zio-test_2.11 jar 1.0.7
dev.zio : zio-test-sbt_2.11 jar 1.0.7

Project Modules

There are no modules declared in this project.

Maven Central Sonatype Nexus (Snapshots)

ZIO AMQP

ZIO AMQP is a ZIO-based wrapper around the RabbitMQ client. It provides a streaming interface to AMQP queues and helps to prevent you from shooting yourself in the foot with thread-safety issues.

Installation

Add to your build.sbt:

libraryDependencies += "nl.vroste" %% "zio-amqp" % "<version>"

The latest version is built against ZIO 1.0.1.

Consuming

The example below creates a connection to an AMQP server and then creates a channel. Both are created as Managed resources, which means they are closed automatically after using even in the face of errors.

The example then creates a stream of the messages consumed from a queue named "queueName". Each received message is acknowledged back to the AMQP server.

import com.rabbitmq.client.ConnectionFactory
import nl.vroste.zio.amqp._
import java.net.URI
import zio._
import zio.blocking._
import zio.console._

val channelM: ZManaged[Blocking, Throwable, Channel] = for { 
  connection <- Amqp.connect(URI.create("amqp://my_amqp_server_uri"))
  channel <- Amqp.createChannel(connection)
} yield channel


val effect: ZIO[Blocking with Console, Throwable, Unit] = channelM.use { channel =>
    channel
    .consume(queue = "queueName", consumerTag = "test")
    .mapM { record =>
      val deliveryTag = record.getEnvelope.getDeliveryTag
      putStrLn(s"Received ${deliveryTag}: ${new String(record.getBody)}") *> 
        channel.ack(deliveryTag)
    }
    .take(5)
    .runDrain
}

See the ZIO documentation for more information on how to run this effect or integrate with an existing application.

Versions

Version
0.2.0
0.1.5