AMQP 0-9-1 Overview

AMQP Messages

An AMQP message is the data transported from a producer to a consumer through the LavinMQ message broker. It can for example contain information that tells a system to perform a task, reports on a finished task, or simply carries data. Every message consists of a payload and a set of attributes.

Message Components

An AMQP message is built from two essential parts: the payload and a set of attributes. The payload is the actual data, while the attributes are the metadata that tell the broker how to handle it.

Message payload

This is the actual data to send, it can be any binary format. The broker does not inspect or modify the payload; it only transports it.

Payload encoding

Payload encoding is a key used by some client tools and APIs, like the LavinMQ HTTP API, to define how the payload should be interpreted before it is sent to the broker. This key specifies whether the payload should be handled as a string (UTF-8 encoded) or as base64. Payload encoding is not part of the standard AMQP protocol.

Delivery mode

In LavinMQ, every message sent is persistent by default. This ensures that all messages are saved to disk and will survive a broker restart, guaranteeing message durability.

Routing key

The routing key is a message attribute that the exchange looks at when deciding how to route the message to one or more queues, depending on its type.

Attributes

These are the meta-information that tell the broker how to handle the message. This includes both standard properties and custom headers. Properties are a predefined set of fields from the AMQP protocol, such as content-type and delivery-mode.

[Properties]

content_type Describes the content of the message payload, using a MIME type (e.g., application/json, text/plain). Content type is used by applications, not core LavinMQ.
content_encoding Specifies the encoding of the payload (e.g., gzip, deflate). Content encoding is used by applications, not core LavinMQ.

Default: application/json
expiration A string representing the message's time-to-live (TTL) in milliseconds.
priority A number from 0 to 9 to set message priority. Read more about [message priority](/documentation/message-priority).
message_id A unique identifier for the message.
timestamp Application-provided timestamp.
type The name of the message type, such as a command or event name.
user_id The ID of the user who published the message.
app_id The name of the application that published the message.
correlation_id Used to correlate a response message with a request message.
reply_to The name of a queue where the consumer should send a reply. This property is essential for implementing a request-response pattern, allowing a client to receive a specific response to a message it has sent.

Custom headers

Custom headers are a flexible key-value map for adding application-specific metadata.

Example message

{
  "properties": {
    "content_type": "application/json",
    "content_encoding": "text/plain"
  },
  "routing_key": "my-key",
  "payload": "my-body",
  "payload_encoding": "string"
}

Message acknowledgements

Messages in transit between LavinMQ and the consumer might get lost and have to be re-sent. This can occur when a connection fails or during other events that disconnect the receiving service (consumer) from LavinMQ. The use of consumer acknowledgments assures that messages have been delivered. When it comes to message publishing, a publish confirm is the same concept.

Read more about consumer acknowledgments.

Message ordering in LavinMQ

Messages in LavinMQ are placed onto the queue in the sequential order in which they are received. The first message is placed in position 1, the second message in position 2, and so on. Messages are then consumed from the head of the queue, meaning that message 1 gets consumed first. This is called the FIFO method (first in first out).

Read more about message ordering in LavinMQ.

Details on the message store in LavinMQ

All routed messages in LavinMQ are written directly to the disk into something called a Message Store. The Message Store is a series of files (segments). A routed message is located in the Message Store, with a reference from the queue’s index to the message store.

Message size

The default message size limit in LavinMQ is 128 MB. This limit is on the message payload and can be configured. It’s generally recommended to keep messages small. Larger messages can consume more memory and disk resources, potentially affecting broker performance and stability. Read more about message configurations.


Ready to take the next steps?

Managed LavinMQ instance via CloudAMQP

LavinMQ has been built with performance and ease of use in mind - we've benchmarked a throughput of about 1,000,000 messages/sec . You can try LavinMQ without any installation hassle by creating a free instance on CloudAMQP. Signing up is a breeze.

Get started with CloudAMQP ->

Help and feedback

We welcome your feedback and are eager to address any questions you may have about this piece or using LavinMQ. Join our Slack channel to connect with us directly. You can also find LavinMQ on GitHub.


Can’t find what you’re looking for? Let us know
Was this helpful?

Search