activemq.org › Handbook › AMQP: 0-9-1 vs 1.0, and which brokers speak which
HandbookAMQP: 0-9-1 vs 1.0, and which brokers speak which
AMQP, the Advanced Message Queuing Protocol, is an open wire-level protocol for messaging, but the name covers two different protocols. AMQP 0-9-1 defines a broker model of exchanges, queues and bindings, the model RabbitMQ implements; AMQP 1.0 is an OASIS and ISO/IEC standard that defines a symmetric protocol for exchanging messages between two parties. They are not two versions of one protocol: when a client connects, the protocol header it sends says which of the two it wants.
ActiveMQ Classic and Apache Artemis (formerly ActiveMQ Artemis) implement AMQP 1.0. RabbitMQ speaks both, and has supported AMQP 1.0 natively since RabbitMQ 4.0. This page compares the two protocols, shows which broker speaks which, and covers the AMQP connector and port 5672 in each broker. The official ActiveMQ documentation is on activemq.apache.org, and Artemis's is on artemis.apache.org.
What is AMQP?
The AMQP 1.0 specification describes AMQP as an open internet protocol for business messaging: a binary wire-level protocol for the reliable exchange of messages between two parties. AMQP 1.0 became an OASIS Standard on 29 October 2012 and is also the international standard ISO/IEC 19464. Its specification is layered in parts: the type system and encoding, the transport, messaging, transactions, and security.
AMQP 0-9-1, in RabbitMQ's words, is not an official standard. RabbitMQ's documentation describes it as a protocol that lets conforming client applications communicate with conforming messaging brokers, and it spells out how those brokers route messages.
AMQP 0-9-1 vs AMQP 1.0: two different protocols
The difference is not a version bump. AMQP 0-9-1 describes a broker and what lives inside it. Publishers send messages to exchanges; exchanges route copies to queues according to rules called bindings; consumers read from queues. Applications themselves, not a broker administrator, mostly define these entities and the routing, which is why RabbitMQ calls 0-9-1 a programmable protocol. It defines four exchange types: direct, fanout, topic and headers.
AMQP 1.0 works differently. The specification says it makes no wire-level distinction between clients and brokers: the protocol is symmetric. Messages travel over links, and an address says where a message is sent to or consumed from. What an address refers to inside a broker, and how it is resolved, is left to each implementation, so different AMQP 1.0 brokers can interpret the same address differently.
| AMQP 0-9-1 | AMQP 1.0 | |
|---|---|---|
| Standard status | Not an official standard | OASIS Standard (2012) and ISO/IEC 19464 |
| What it defines | A broker model: exchanges, queues and bindings, declared by applications | A symmetric transport and message format; the broker's internal model is up to the implementation |
| Where messages are sent | To an exchange, with a routing key | To an address on a link; each broker defines its address syntax |
| Connection start | Client sends a protocol header asking for 0-9-1 | Client sends a protocol header asking for 1.0 |
| Port | 5672 on RabbitMQ, shared with 1.0 | 5672 on ActiveMQ Classic (once enabled), Artemis and RabbitMQ |
| Brokers | RabbitMQ | ActiveMQ Classic, Apache Artemis, RabbitMQ |
The protocol header is where the two part ways. Before sending any AMQP frames, the client announces which protocol it wants, and RabbitMQ uses that header to decide whether a connection on port 5672 is AMQP 1.0 or 0-9-1. ActiveMQ Classic and Artemis document AMQP 1.0 only, so an AMQP 0-9-1 client library is the wrong tool for them.
Which brokers speak which AMQP?
| Broker | AMQP 0-9-1 | AMQP 1.0 | Port |
|---|---|---|---|
| ActiveMQ Classic | Not documented | Yes, since 5.8 | 5672 once the amqp transport connector is uncommented; it is commented out in the default configuration of 6.4.0 and 5.19.12 |
| Apache Artemis | Not documented | Yes | 5672 and 61616 by default |
| RabbitMQ | Yes | Yes, natively since 4.0 | 5672 for both |
RabbitMQ's documentation recommends AMQP 1.0 for new applications and notes that more brokers support AMQP 1.0 than 0-9-1. For a wider comparison of the brokers themselves, see ActiveMQ vs RabbitMQ and ActiveMQ Classic vs Artemis.
AMQP in ActiveMQ Classic
ActiveMQ supports AMQP 1.0 from version 5.8. You enable it with a transport connector whose URI uses the amqp scheme. From the ActiveMQ Classic AMQP documentation, which applies to ActiveMQ 5.8 and later:
<transportConnectors>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672"/>
</transportConnectors>
The ActiveMQ AMQP page says this connector is enabled in the default server configuration. In the conf/activemq.xml shipped with ActiveMQ 6.4.0, and in the one shipped with 5.19.12, it is not: only the OpenWire connector on 61616 is enabled, and the AMQP line is commented out under a note that additional transports are disabled by default to reduce the exposed attack surface. Clients cannot connect on 5672 until you enable it. The line as it appears in both files:
<!-- <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=10485760"/> -->
Uncomment that line to accept AMQP clients on 5672. The shipped file recommends the secured variant, amqp+ssl, in production; the AMQP page's SSL example listens on 5671. For better scalability the documentation recommends amqp+nio instead of the default TCP transport; it generally uses far fewer threads than the standard connector. The full list of default ports is on ActiveMQ ports.
Other behavior documented for ActiveMQ Classic:
- Authentication: the broker accepts SASL PLAIN, and authorization policies apply to destinations as usual.
- Destinations: prefix the address with
queue://ortopic://. Without a prefix, the destination is a queue. - Credit and prefetch: an AMQP receiver maps to a JMS consumer. The broker honors the credit the client grants, or uses 1000 if the client sets none;
transport.prefetchon the connector overrides the client. The broker's own receiving link uses 1000 credits by default, changed withtransport.producerCredit. - Mapping to JMS: the
transport.transformeroption choosesnative(the default, which wraps the AMQP message bytes in a JMSBytesMessageand maps the headers),raw, orjms, which maps the AMQP body to the JMS body. - Client library: the AMQP page points to Apache Qpid Proton.
AMQP in Apache Artemis
Artemis supports the AMQP 1.0 specification. By default its configuration has acceptors that take AMQP connections on ports 61616 and 5672, and the documentation says any AMQP 1.0 client can be used, listing Qpid clients, .NET clients and the JavaScript client Rhea among others. Its Java example uses the Qpid JMS client.
Artemis accepts the PLAIN, ANONYMOUS and GSSAPI SASL mechanisms. It does not convert messages that arrive and leave over AMQP. AMQP itself has no notion of topics, so Artemis treats a receiving link that attaches to an address with only multicast enabled as a subscription. That is how AMQP clients consume publish/subscribe messages there.
AMQP in RabbitMQ
From the RabbitMQ 4.4 documentation:
- AMQP 1.0 has been supported natively since RabbitMQ 4.0, and RabbitMQ supports both AMQP 1.0 and 0.9.1 out of the box, without plugins.
- By default it listens on port 5672 for both protocols and tells them apart by the protocol header the client sends.
- AMQP 1.0 connections must use SASL; RabbitMQ rejects a 1.0 client that does not.
- AMQP 1.0 addresses map onto the 0-9-1 model. With address format v2, clients send to
/exchanges/:exchange/:routing-key,/exchanges/:exchangeor/queues/:queue, and consume from/queues/:queue. The older v1 format is deprecated since 4.0. - Some features exist only in 0-9-1. RabbitMQ gives 0-9-1 limited transaction support, while AMQP 1.0 currently does not support transactions there, and per-exchange and per-queue message rates in the management UI are shown only for 0-9-1 connections.
AMQP client libraries
Because AMQP 1.0 is a standard, an AMQP 1.0 client is not tied to one broker. RabbitMQ states that any AMQP 1.0 client should be able to communicate with it, and its team publishes AMQP 1.0 clients for Java and .NET. The ActiveMQ Classic documentation names Apache Qpid Proton, and the Artemis documentation uses the Qpid JMS client in its Java example. The RabbitMQ documentation also notes that the AMQP 0-9-1 client ecosystem is currently more extensive.
What does not carry over between brokers is the address syntax. ActiveMQ Classic expects queue:// and topic:// prefixes, while RabbitMQ's v2 format expects /queues/ and /exchanges/ paths, so plan to change addresses when you move an AMQP 1.0 application from one broker to another.
See also STOMP protocol.
Common problems
- Connection refused on port 5672 against ActiveMQ Classic. The AMQP connector is commented out in the
activemq.xmlshipped with 6.4.0 and 5.19.12; uncomment it or add your own. - An AMQP 0-9-1 client cannot connect to ActiveMQ or Artemis. Both document AMQP 1.0 only. Use an AMQP 1.0 client.
- Messages end up on a queue when you meant a topic in ActiveMQ Classic. Addresses without a prefix are queues; use
topic://. - JMS consumers receive a
BytesMessageinstead of the expected body type. The defaultnativetransformer wraps the AMQP message in aBytesMessage; settransport.transformer=jmsto map bodies. - RabbitMQ rejects an AMQP 1.0 connection. RabbitMQ requires SASL for AMQP 1.0.
Frequently asked questions
What is the difference between AMQP 0-9-1 and AMQP 1.0?
They are different protocols, not two versions of one. AMQP 0-9-1 defines a broker model of exchanges, queues and bindings that applications declare themselves, while AMQP 1.0 is an OASIS and ISO/IEC 19464 standard with a symmetric design that leaves what an address means inside a broker to each implementation. A client says which one it wants in the protocol header it sends when it connects.
Does ActiveMQ support AMQP?
Yes. ActiveMQ Classic supports AMQP 1.0 from version 5.8, and Apache Artemis supports AMQP 1.0 as well. Neither documents AMQP 0-9-1, so use an AMQP 1.0 client with them.
What port does AMQP use?
5672 in all three brokers covered here. In ActiveMQ Classic 6.4.0 and 5.19.12 the amqp connector on 5672 is commented out in the shipped conf/activemq.xml, so you must uncomment it before clients can connect. Artemis accepts AMQP on 5672 and 61616 by default, and RabbitMQ serves both AMQP 1.0 and 0-9-1 on 5672.
Does RabbitMQ support AMQP 1.0?
Yes. RabbitMQ has supported AMQP 1.0 natively since 4.0, without plugins, alongside AMQP 0-9-1. It requires SASL on AMQP 1.0 connections and recommends AMQP 1.0 for new applications.
Which AMQP client library should I use?
Any AMQP 1.0 client should work with an AMQP 1.0 broker. The ActiveMQ Classic documentation names Apache Qpid Proton, the Artemis documentation uses the Qpid JMS client in its Java example and lists Rhea for JavaScript, and the RabbitMQ team publishes AMQP 1.0 clients for Java and .NET. Expect to change address syntax between brokers.
Related guides
- STOMP protocol explained, with ActiveMQ, RabbitMQ and Python
- ActiveMQ vs RabbitMQ: features, protocols and when to use each
- ActiveMQ ports: defaults and how to change them
- ActiveMQ Artemis vs ActiveMQ Classic: differences and migration
- What is a message broker?
- All handbook guides
Sources
- OASIS AMQP 1.0 Part 0: Overview docs.oasis-open.org
- RabbitMQ: AMQP 1.0 www.rabbitmq.com
- RabbitMQ: AMQP 0-9-1 Model Explained www.rabbitmq.com
- ActiveMQ: AMQP activemq.apache.org
- ActiveMQ 6.4.0 default conf/activemq.xml raw.githubusercontent.com
- ActiveMQ 5.19.12 default conf/activemq.xml raw.githubusercontent.com
- Apache Artemis: AMQP artemis.apache.org
- Apache Artemis: News artemis.apache.org