View Source Rabbit.Message (Rabbit v0.20.0)

A message consumed by a Rabbit.Consumer.

After starting a consumer, any message passed to the Rabbit.Consumer.handle_message/1 callback will be wrapped in a messsage struct. The struct has the following fields:

  • :consumer - The PID of the consumer process.
  • :module - The module of the consumer process.
  • :channel - The AMQP.Channel being used by the consumer.
  • :payload - The raw payload of the message.
  • :decoded_payload - If the message has a content type - this will be the payload decoded using the applicable serializer.
  • :meta - The metadata sent when publishing or set by the broker.
  • :custom_meta - The custom metadata included when starting a consumer.
  • :error_reason - The reason for any error that occurs during the message handling callback.
  • :error_stack - The stacktrace that might accompany the error.

Summary

Functions

Awknowledges a message.

Negative awknowledges a message.

Rejects a message.

Types

@type t() :: %Rabbit.Message{
  channel: AMQP.Channel.t(),
  consumer: pid(),
  custom_meta: map(),
  decoded_payload: any(),
  error_reason: any(),
  error_stack: nil | list(),
  meta: map(),
  module: module(),
  payload: binary()
}

Functions

Link to this function

ack(message, opts \\ [])

View Source
@spec ack(
  t(),
  keyword()
) :: :ok | {:error, :blocked | :closing}

Awknowledges a message.

Options

  • :multiple - If true, all messages up to the one specified by its delivery_tag are considered acknowledged by the server.
Link to this function

nack(message, opts \\ [])

View Source
@spec nack(
  t(),
  keyword()
) :: :ok | {:error, :blocked | :closing}

Negative awknowledges a message.

Options

  • :multiple - If true, all messages up to the one specified by it delivery_tag are considered acknowledged by the server.
  • :requeue - If true, the message will be returned to the queue and redelivered to the next available consumer.
Link to this function

new(consumer, module, channel, payload, meta, custom_meta)

View Source
@spec new(Rabbit.Consumer.t(), module(), AMQP.Channel.t(), any(), map(), map()) :: t()

Creates a new message struct.

Link to this function

reject(message, opts \\ [])

View Source
@spec reject(
  t(),
  keyword()
) :: :ok | {:error, :blocked | :closing}

Rejects a message.

Options

  • :requeue - If true, the message will be returned to the queue and redelivered to the next available consumer.