The canonical message envelope for all inter-service communication.
Every message flowing through phoenix_micro — whether published to a broker,
consumed from a queue, or passed through an RPC call — is wrapped in this struct.
Fields
:id— UUID v4; assigned at publish time; used for idempotency tracking.:topic— The routing key / topic name (e.g."payments.created").:payload— The decoded message body. Any term.:headers— Arbitrary key-value metadata map (string keys).:attempt— Delivery attempt counter; starts at 1, incremented on retry.:timestamp— UTCDateTimeof original publish time.:reply_to— Optional reply-topic for RPC correlation.:correlation_id— Optional ID linking an RPC request to its response.:raw— The raw broker-native message (transport-specific). Opaque.:acked?— Whether this message has been ack'd/nack'd by the consumer.:metadata— Transport-specific extra data (partition, offset, routing key, …).
Summary
Functions
Marks the message as acknowledged.
Returns a new message with the attempt counter incremented.
Creates a new message with a generated UUID and current UTC timestamp.
Adds or updates a header.
Merges additional metadata into the message.
Types
Functions
Marks the message as acknowledged.
Returns a new message with the attempt counter incremented.
Creates a new message with a generated UUID and current UTC timestamp.
Examples
iex> msg = PhoenixMicro.Message.new("payments.created", %{amount: 100})
iex> msg.topic
"payments.created"
iex> msg.attempt
1
Adds or updates a header.
Merges additional metadata into the message.