<commit_before><!--
Copyright (c) 2007-2019 Pivotal Software, Inc.

All rights reserved. This program and the accompanying materials
are made available under the terms of the under the Apache License,
Version 2.0 (the "License”); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# AMQP 0-9-1 Model Explained

## <a id="overview" class="anchor" href="#overview">Overview</a>

This guide provides an overview of the AMQP 0-9-1 protocol, one of the protocols
supported by RabbitMQ.

## <a id="highlevel-overview" class="anchor" href="#highlevel-overview">High-level Overview of AMQP 0-9-1 and the AMQP Model</a>

### <a id="what-is-amqp" class="anchor" href="#what-is-amqp">What is AMQP 0-9-1?</a>

AMQP 0-9-1 (Advanced Message Queuing Protocol) is a messaging
protocol that enables conforming client applications to
communicate with conforming messaging middleware brokers.

### <a id="brokers-role" class="anchor" href="#brokers-role">Brokers and Their Role</a>

Messaging brokers receive messages from _[publishers](/publishers.html)_
(applications that publish them, also known as producers) and route them to
_[consumers](/consumers.html)_ (applications that process them).

Since it is a network protocol, the publishers,
consumers and the broker can all reside on
different machines.

### <a id="amqp-model" class="anchor" href="#amqp-model">AMQP 0-9-1 Model in Brief</a>

The AMQP 0-9-1 Model has the following view of the world:
messages are published to _exchanges_,
which are often compared to post offices or mailboxes. Exchanges then
distribute message copies to _queues_ using rules called
_bindings_. Then the broker either deliver messages to
consumers subscribed to queues, or consumers
fetch/pull messages from queues on demand.

<img src="/img/tutorials/intro/hello-world-example-routing.png" alt="Publish path from publisher to consumer via exchange and queue" />

When publishing a message, publishers may specify various
_message attributes_ (message meta-data). Some of this
meta-data may be used by the broker, however, the rest of it
is completely opaque to the broker and is only used by
applications that receive the message.

Networks are unreliable and applications may fail to process
messages therefore the AMQP 0-9-1 model has a notion of
_message acknowledgements_: when a message is delivered
to a consumer the consumer _notifies the broker_,
either automatically or as soon as the application
developer chooses to do so. When message acknowledgements
are in use, a broker will only completely remove a message
from a queue when it receives a notification for that message
(or group of messages).

In certain situations, for example, when a message cannot
be routed, messages may be _returned_ to publishers,
dropped, or, if the broker implements an extension,
placed into a so-called "dead letter queue". Publishers choose
how to handle situations like this by publishing messages
using certain parameters.

Queues, exchanges and bindings are collectively referred to as _AMQP entities_.

### <a id="programmable-protocol" class="anchor" href="#programmable-protocol">AMQP 0-9-1 is a Programmable Protocol</a>

AMQP 0-9-1 is a programmable protocol in the sense that AMQP 0-9-1
entities and routing schemes are primarily defined by applications
themselves, not a broker administrator. Accordingly,
provision is made for protocol operations that declare
queues and exchanges, define bindings between them,
subscribe to [queues](/queues.html) and so on.

This gives application developers a lot of freedom but
also requires them to be aware of potential definition
conflicts. In practice, definition conflicts are rare and
often indicate a misconfiguration.

Applications declare the AMQP 0-9-1 entities that they need,
define necessary routing schemes and may choose to delete
AMQP 0-9-1 entities when they are no longer used.


## <a id="exchanges" class="anchor" href="#exchanges">Exchanges and Exchange Types</a>

_Exchanges_ are AMQP 0-9-1 entities where messages are
sent. Exchanges take a message and route it into zero or
more queues. The routing algorithm used depends on the
_exchange type_ and rules called _bindings_.
AMQP 0-9-1 brokers provide four exchange types:

<table>
  <thead>
    <th>Name</th>
    <th>Default pre-declared names</th>
  </thead>
  <tr>
    <td>Direct exchange</td>
    <td>(Empty string) and amq.direct</td>
  </tr>
  <tr>
    <td>Fanout exchange</td>
    <td>amq.fanout</td>
  </tr>
  <tr>
    <td>Topic exchange</td>
    <td>amq.topic</td>
  </tr>
  <tr>
    <td>Headers exchange</td>
    <td>amq.match (and amq.headers in RabbitMQ)</td>
  </tr>
</table>

Besides the exchange type, exchanges are declared with a number of
attributes, the most important of which are:

 * Name<commit_msg>Update amqp-concepts.md<commit_after><!--
Copyright (c) 2007-2019 Pivotal Software, Inc.

All rights reserved. This program and the accompanying materials
are made available under the terms of the under the Apache License,
Version 2.0 (the "License”); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# AMQP 0-9-1 Model Explained

## <a id="overview" class="anchor" href="#overview">Overview</a>

This guide provides an overview of the AMQP 0-9-1 protocol, one of the protocols
supported by RabbitMQ.

## <a id="highlevel-overview" class="anchor" href="#highlevel-overview">High-level Overview of AMQP 0-9-1 and the AMQP Model</a>

### <a id="what-is-amqp" class="anchor" href="#what-is-amqp">What is AMQP 0-9-1?</a>

AMQP 0-9-1 (Advanced Message Queuing Protocol) is a messaging
protocol that enables conforming client applications to
communicate with conforming messaging middleware brokers.

### <a id="brokers-role" class="anchor" href="#brokers-role">Brokers and Their Role</a>

Messaging brokers receive messages from _[publishers](/publishers.html)_
(applications that publish them, also known as producers) and route them to
_[consumers](/consumers.html)_ (applications that process them).

Since it is a network protocol, the publishers,
consumers and the broker can all reside on
different machines.

### <a id="amqp-model" class="anchor" href="#amqp-model">AMQP 0-9-1 Model in Brief</a>

The AMQP 0-9-1 Model has the following view of the world:
messages are published to _exchanges_,
which are often compared to post offices or mailboxes. Exchanges then
distribute message copies to _queues_ using rules called
_bindings_. Then the broker either deliver messages to
consumers subscribed to queues, or consumers
fetch/pull messages from queues on demand.

<img src="/img/tutorials/intro/hello-world-example-routing.png" alt="Publish path from publisher to consumer via exchange and queue" />

When publishing a message, publishers may specify various
_message attributes_ (message meta-data). Some of this
meta-data may be used by the broker, however, the rest of it
is completely opaque to the broker and is only used by
applications that receive the message.

Networks are unreliable and applications may fail to process
messages therefore the AMQP 0-9-1 model has a notion of
_message acknowledgements_: when a message is delivered
to a consumer the consumer _notifies the broker_,
either automatically or as soon as the application
developer chooses to do so. When message acknowledgements
are in use, a broker will only completely remove a message
from a queue when it receives a notification for that message
(or group of messages).

In certain situations, for example, when a message cannot
be routed, messages may be _returned_ to publishers,
dropped, or, if the broker implements an extension,
placed into a so-called "dead letter queue". Publishers choose
how to handle situations like this by publishing messages
using certain parameters.

Queues, exchanges and bindings are collectively referred to as _AMQP entities_.

### <a id="programmable-protocol" class="anchor" href="#programmable-protocol">AMQP 0-9-1 is a Programmable Protocol</a>

AMQP 0-9-1 is a programmable protocol in the sense that AMQP 0-9-1
entities and routing schemes are primarily defined by applications
themselves, not a broker administrator. Accordingly,
provision is made for protocol operations that declare
queues and exchanges, define bindings between them,
subscribe to [queues](/queues.html) and so on.

This gives application developers a lot of freedom but
also requires them to be aware of potential definition
conflicts. In practice, definition conflicts are rare and
often indicate a misconfiguration.

Applications declare the AMQP 0-9-1 entities that they need,
define necessary routing schemes and may choose to delete
AMQP 0-9-1 entities when they are no longer used.


## <a id="exchanges" class="anchor" href="#exchanges">Exchanges and Exchange Types</a>

_Exchanges_ are AMQP 0-9-1 entities where messages are
sent. Exchanges take a message and route it into zero or
more queues. The routing algorithm used depends on the
_exchange type_ and rules called _bindings_.
AMQP 0-9-1 brokers provide four exchange types:

<table>
  <thead>
    <th>Exchange type</th>
    <th>Default pre-declared names</th>
  </thead>
  <tr>
    <td>Direct exchange</td>
    <td>(Empty string) and amq.direct</td>
  </tr>
  <tr>
    <td>Fanout exchange</td>
    <td>amq.fanout</td>
  </tr>
  <tr>
    <td>Topic exchange</td>
    <td>amq.topic</td>
  </tr>
  <tr>
    <td>Headers exchange</td>
    <td>amq.match (and amq.headers in RabbitMQ)</td>
  </tr>
</table>

Besides the exchange type, exchanges are declared with a number of
attributes, the most important of which are:

 * Name
{'fraction_non_alphanumeric': 0.07799980693117096, 'fraction_numerical': 0.011004923255140457, 'mean_word_length': 4.651936715766503, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '948602', 'n_tokens_mistral': 3011, 'n_tokens_neox': 2792, 'n_words': 1367}