← ZIO SQS docs

zio.sqs.producer

Members list

Type members

Classlikes

trait Producer[T]

Publishes events of type T to an SQS queue. Create an instance with Producer.make inside a Scope, then publish with the methods below.

Publishes events of type T to an SQS queue. Create an instance with Producer.make inside a Scope, then publish with the methods below.

import zio._
import zio.aws.sqs.Sqs
import zio.sqs.producer._
import zio.sqs.serialization.Serializer

def publish(queueUrl: String): ZIO[Sqs, Throwable, Unit] =
 ZIO.scoped {
   for {
     producer <- Producer.make(queueUrl, Serializer.serializeString)
     _        <- producer.produce(ProducerEvent("hello"))
   } yield ()
 }

Type parameters

T

type of the event to publish

Attributes

Companion
object
Source
Producer.scala
Supertypes
class Object
trait Matchable
class Any
object Producer

Factory for Producer.

Factory for Producer.

Attributes

Companion
trait
Source
Producer.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Producer.type
object ProducerError

Factory and recoverability check for ProducerError.

Factory and recoverability check for ProducerError.

Attributes

Companion
class
Source
ProducerError.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ProducerError[T](senderFault: Boolean, code: String, message: Option[String], event: ProducerEvent[T]) extends RuntimeException

Encodes an error for the published message. Its getMessage has the form senderFault: , code: <code>, message:. Fields senderFault, code, message correspond to the respective fields in BatchResultErrorEntry

Encodes an error for the published message. Its getMessage has the form senderFault: , code: <code>, message:. Fields senderFault, code, message correspond to the respective fields in BatchResultErrorEntry

Type parameters

T

type of the event.

Value parameters

code

an error code representing why the action failed on this entry.

event

event that caused this failure.

message

a message explaining why the action failed on this entry.

senderFault

whether the error happened due to the caller of the batch API action.

Attributes

Companion
object
Source
ProducerError.scala
Supertypes
trait Product
trait Equals
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
final case class ProducerEvent[T](data: T, attributes: Map[String, MessageAttributeValue], groupId: Option[String], deduplicationId: Option[String], delay: Option[Duration] = ...)

Event to publish to SQS.

Event to publish to SQS.

Type parameters

T

type of the payload for the event.

Value parameters

attributes

a map of attributes to set.

data

payload to publish.

deduplicationId

token used for deduplication of sent messages.

delay

in order to delay delivery of the message. Allowed values: 0 to 15 minutes. The producer sends the whole seconds of the delay; any fraction of a second is dropped.

groupId

assigns a specific message group to the message.

Attributes

Companion
object
Source
ProducerEvent.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ProducerEvent

Factory for ProducerEvent.

Factory for ProducerEvent.

Attributes

Companion
class
Source
ProducerEvent.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ProducerSettings(batchSize: Int = ..., duration: Duration = ..., parallelism: Int = ..., retryDelay: Duration = ..., retryMaxCount: Int = ...)

Settings for the producer. Creating the settings with a batchSize above 10 throws a java.lang.IllegalArgumentException.

Settings for the producer. Creating the settings with a batchSize above 10 throws a java.lang.IllegalArgumentException.

Value parameters

batchSize

size of the batch to use. Up to 10 messages can be buffered and sent as a batch request.

duration

time to wait for the batch to be full (have the specified batchSize).

parallelism

number of concurrent requests to make to SQS.

retryDelay

time to wait before retrying event republishing if it failed with a recoverable error.

retryMaxCount

the maximum number of retries for an event that fails with a recoverable error (see ProducerError.isRecoverable).

Attributes

Source
ProducerSettings.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

Specifies the result of publishing en event. The result either an error zio.sqs.producer.ProducerError or the event itself zio.sqs.producer.ProducerEvent

Specifies the result of publishing en event. The result either an error zio.sqs.producer.ProducerError or the event itself zio.sqs.producer.ProducerEvent

Type parameters

T

type of the event to publish

Attributes

Source
package.scala