Introduction
Configuration
Language Support
AMQP 0-9-1 Overview
More Exchange Types
More Consumer Features
Queue Deep-dive
Other Features
Reliable Message Delivery
High Availability
Monitoring
Management HTTP API
Tutorials
Networking
LavinMQ CLI
The Advanced Message Queuing Protocol (AMQP) Overview
LavinMQ implements an extension of the open standard AMQP 0.9.1 specification. It is the protocol used as the basis for a set of standards controlling the entire message passing process.
What is the Advanced Message Queuing Protocol?
AMQP is a protocol for message-oriented middleware.
AMQP enables the asynchronous transfer of messages regardless of hardware and programming language. All AMQP client libraries work with LavinMQ and there are AMQP client libraries for almost every platform out there, including Ruby, Node.js, Java, and Python.
When should I use AMQP?
AMQP is an efficient and reliable messaging protocol that can be used to build robust, cross-platform, messaging applications. Use an AMQP message broker in a situation where you need secure and fast message delivery between your client and the message broker.
AMQP
AMQP features message queuing and orientation, similar to other message queuing protocols. Routing is another feature and is basically the process by which an exchange decides which queues to place your message on. Messages in LavinMQ are routed from the exchange to the queue depending on exchange types and keys. Key features of AMQP include reliability and security.
AMQP is a binary protocol, suitable for large amounts of data. It is optimized for machine efficiency and speed instead of human readability. Another valuable characteristic of the AMQP protocol is that it has multiple implementation standards, meaning that you can run AMQP with various message brokers and applications.
Main concepts in AMQP
Typically, one client called the producer sends a message to an exchange. Exchanges then distribute messages and message copies to queues, depending on rules defined by the exchange type and routing key provided in the message. The message is finally consumed by a subscribing service.
Message Queue
Providing a place to store messages, a queue acts like a buffer. Messages can be consumed from this queue. A queue can be declared with a number of attributes during creation. For instance, it can be marked as durable, auto-delete, and exclusive, where exclusive means that it can be used by only one connection and this queue will be deleted when that connection closes.
Read more about queues.
Exchange Types and Bindings
A channel routes messages to a queue depending on the exchange type and bindings between the exchange and the queue. For a queue to receive messages, it must be bound to at least one exchange. LavinMQ provides four main exchange types - direct exchange, fanout exchange, topic exchange, and header exchange. An exchange can be declared with a number of attributes during creation. For instance, it can be marked as durable so that it survives a broker restart, or it can be marked as auto-delete meaning that it’s automatically deleted when the last queue is unbound. A binding is a relation between a queue and an exchange consisting of a set of rules that the exchange uses (among other things) to route messages to queues.
Read more about exchange types and bindings.
Message and Content
A message is an entity sent from the publisher to the queue and finally subscribed to by the consumer. Each message contains a set of headers defining properties such as life duration, durability, and priority.
AMQP 0.9.1 also has a built-in feature called message acknowledgment that is used to confirm message delivery and/or processing.
Read more about messages.
Connections and channels
A connection in AMQP 0.9.1 is a network connection between your application and the LavinMQ server, e.g. a TCP/IP socket connection.
A channel is a virtual connection inside a connection, between two LavinMQ (AMQP) peers. Message publishing or consuming to or from a queue is performed over a channel. One single connection can have multiple channels.
More information about connections and channels and the relationship between them can be found in the documentation for connections and channels
Virtual Hosts
Virtual hosts (vhost) provide a way to segregate applications in the broker. Depending on the vhost, different users can have different access. Queues and exchanges are created so they only exist in one vhost.
Read more about vhosts.
AMQP Methods
AMQP 0.9.1 provides a number of methods or operations that can be performed. Some examples of AMQP methods are opening a channel, declaring a queue, or deleting an exchange (channel.open, queue.declare or exchange.delete-ok).
Other information is passed in the body and is referred to as application data. The message body will be located here. Application data may take any form or encoding.
Ready to take the next steps? Here are some things you should keep in mind:
Managed LavinMQ instance on 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.
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.