KubeMQ.QueueMessage (kubemq v1.0.1)

Copy Markdown View Source

Message for the KubeMQ Queues pattern.

Supports delivery policies (expiration, delay, dead-letter) and server-populated attributes on receive.

Fields

  • id (String.t() | nil) — Unique message identifier. Auto-generated if nil.

  • channel (String.t()) — Target queue channel name. Required for sending.
  • metadata (String.t() | nil) — Optional metadata string.

  • body (binary() | nil) — Message payload.

  • client_id (String.t() | nil) — Sender identifier. Set automatically by KubeMQ.Client.

  • tags (%{String.t() => String.t()}) — Key-value tags. Default: %{}.
  • policy (KubeMQ.QueuePolicy.t() | nil) — Delivery policy (expiration, delay, dead-letter).

  • attributes (KubeMQ.QueueAttributes.t() | nil) — Server-populated attributes (present only on received messages).

Usage

msg = KubeMQ.QueueMessage.new(
  channel: "orders",
  body: payload,
  policy: KubeMQ.QueuePolicy.new(delay_seconds: 30)
)

Summary

Functions

Create a new QueueMessage struct from keyword options.

Types

t()

@type t() :: %KubeMQ.QueueMessage{
  attributes: KubeMQ.QueueAttributes.t() | nil,
  body: binary() | nil,
  channel: String.t(),
  client_id: String.t() | nil,
  id: String.t() | nil,
  metadata: String.t() | nil,
  policy: KubeMQ.QueuePolicy.t() | nil,
  tags: %{required(String.t()) => String.t()}
}

Functions

from_transport(msg)

@spec from_transport(map()) :: t()

new(opts \\ [])

@spec new(keyword()) :: t()

Create a new QueueMessage struct from keyword options.

Options

  • :id — Message ID string (auto-generated if nil)
  • :channel — Target queue channel name (required for sending)
  • :metadata — Metadata string
  • :body — Message payload (binary)
  • :client_id — Client identifier (set automatically by KubeMQ.Client)
  • :tags — Key-value tags map (default: %{})
  • :policyKubeMQ.QueuePolicy struct for delivery policy
  • :attributesKubeMQ.QueueAttributes struct (server-populated on receive)

Examples

iex> msg = KubeMQ.QueueMessage.new(channel: "orders", body: "order-data")
iex> msg.channel
"orders"
iex> msg.tags
%{}