gamqp/amqp091/basic

Publishing, consuming, fetching and acknowledging messages.

Types

pub type ConsumeOptions {
  ConsumeOptions(
    consumer_tag: String,
    no_ack: Bool,
    exclusive: Bool,
    arguments: List(#(String, table.FieldValue)),
  )
}

Constructors

  • ConsumeOptions(
      consumer_tag: String,
      no_ack: Bool,
      exclusive: Bool,
      arguments: List(#(String, table.FieldValue)),
    )

    Arguments

    consumer_tag

    Leave empty to let the broker pick one.

    no_ack

    The broker considers messages acknowledged as soon as it sends them.

    exclusive

    Fail if anyone else consumes from the queue.

    arguments

    Consumer arguments such as x-priority or x-stream-offset.

pub type Fetched {
  Fetched(delivery: event.Delivery, message_count: Int)
}

Constructors

pub type PublishOptions {
  PublishOptions(mandatory: Bool, immediate: Bool)
}

Constructors

  • PublishOptions(mandatory: Bool, immediate: Bool)

    Arguments

    mandatory

    Return the message (see on_return) when no queue is bound for it.

    immediate

    Not supported by RabbitMQ, which closes the connection when it is set.

Values

pub fn ack(
  channel: client.Channel,
  delivery_tag: Int,
  multiple multiple: Bool,
) -> Result(Nil, core.AmqpError)

With multiple, also acknowledges every earlier delivery on the channel.

pub fn cancel(
  channel: client.Channel,
  consumer_tag: String,
) -> Result(Nil, core.AmqpError)

Stops a consumer. Deliveries already sent to it may still be in its mailbox, followed by Cancelled.

pub fn consume(
  channel: client.Channel,
  queue queue: String,
  subject subject: process.Subject(event.ConsumerMessage),
  options options: ConsumeOptions,
) -> Result(String, core.AmqpError)

Starts a consumer that sends every delivery to subject and returns its tag. subject also gets Cancelled when the consumer stops for any reason, so a receive loop knows when to end.

pub fn consume_options() -> ConsumeOptions
pub fn get(
  channel: client.Channel,
  queue: String,
  no_ack no_ack: Bool,
) -> Result(option.Option(Fetched), core.AmqpError)

Fetches one message, or None when the queue is empty. Prefer consume for anything beyond occasional polling.

pub fn nack(
  channel: client.Channel,
  delivery_tag: Int,
  multiple multiple: Bool,
  requeue requeue: Bool,
) -> Result(Nil, core.AmqpError)

Rejects one or (with multiple) several deliveries. Without requeue they are dropped or dead-lettered.

pub fn on_return(
  channel: client.Channel,
  subject: process.Subject(event.Returned),
) -> Result(Nil, core.AmqpError)

Sends unroutable mandatory messages to subject. Replaces any previous listener on this channel.

pub fn publish(
  channel: client.Channel,
  exchange exchange: String,
  routing_key routing_key: String,
  message message: message.Message,
  options options: PublishOptions,
) -> Result(Int, core.AmqpError)

Publishes message to exchange (“” is the default exchange, which routes straight to the queue named by the routing key).

The call returns once the frames are written. In confirm mode it returns the message’s sequence number; otherwise 0.

pub fn publish_options() -> PublishOptions
pub fn qos(
  channel: client.Channel,
  prefetch_count prefetch_count: Int,
  global global: Bool,
) -> Result(Nil, core.AmqpError)

Limits how many unacknowledged deliveries the broker sends. With global the limit is shared by every consumer on the channel; otherwise it applies to each consumer started after this call.

pub fn recover(
  channel: client.Channel,
  requeue requeue: Bool,
) -> Result(Nil, core.AmqpError)

Asks the broker to redeliver every unacknowledged message on the channel.

pub fn reject(
  channel: client.Channel,
  delivery_tag: Int,
  requeue requeue: Bool,
) -> Result(Nil, core.AmqpError)

The standard, single-message form of nack.

✨ Search Document