class

Crabbit::Message

Inherits Reference < Object

Complete AMQP 1.0 message used as a RabbitMQ Stream payload.

A message can contain header, annotations, properties, application properties, one body family, footer, and unknown described sections. Message.new creates a Data-body message; use .data, .sequence, or .value for explicit body construction.

message = Crabbit::Message.new(
  "invoice-created",
  properties: Crabbit::Properties.new(content_type: "text/plain"),
  application_properties: {
    "region" => Crabbit::AMQP::Value.wrap("eu"),
  },
)

Constructors

from_amqp(bytes : Bytes, *, zero_copy : Bool = false) : self

Decodes one complete AMQP message from bytes.

Binary values are copied by default. With zero_copy, Data sections and AMQP binary values may reference bytes directly; the caller must keep that buffer alive and must not mutate it while the message is used.

Source

Instance methods

application_properties

Returns the mutable application-properties map, creating it when absent.

Source
body

Returns the logical Data body as bytes.

A single Data part is returned without copying. Multiple parts are joined into a new slice. Non-Data messages return Bytes.empty.

Source
body_kind

Returns the encoded body family.

Source
data

Returns the mutable list of AMQP Data section payloads.

Source
delivery_annotations

Returns the mutable delivery-annotations map, creating it when absent.

Source
extra_sections

Returns unknown described sections preserved during decoding.

Values added here are encoded after the standard message sections.

Source
header

Returns the optional AMQP header.

Source
message_annotations

Returns the mutable message-annotations map, creating it when absent.

Source
properties

Returns the optional AMQP properties section.

Source
sequences

Returns the mutable list of AMQP Sequence section values.

Source
to_amqp(io : IO) : Nil

Encodes the complete message directly into io.

This overload avoids allocating an intermediate encoded Bytes buffer.

Source
to_amqp

Encodes the complete message to a newly allocated AMQP byte slice.

Source
value

Returns the AMQP Value body, or nil for Data and Sequence bodies.

Source