| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you 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 |
| |
| http://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. |
| |
| --> |
| |
| <section id="Java-Broker-Concepts-Exchanges"> |
| <title>Exchanges</title> |
| <para>An <emphasis>Exchange</emphasis> is a named entity within the <emphasis>Virtual Host</emphasis> which receives |
| messages from producers and routes them to matching message <emphasis>Queue</emphasis>s within the <emphasis>Virtual Host</emphasis>. |
| Message routing occurs based on the particular Exchange's routing algorithm and its configured queue <emphasis>Binding</emphasis>s.</para> |
| <para> |
| The following <emphasis>Exchange</emphasis> types are supported by the <emphasis>Broker</emphasis>: |
| <itemizedlist> |
| <listitem><para><emphasis>Direct</emphasis>: routes messages to queues based on an exact match between |
| the routing key of the message, and the binding key used to bind the queue to the exchange |
| </para></listitem> |
| <listitem><para><emphasis>Topic</emphasis>: routes messages to queues based on heirarchical pattern matching between the routing |
| key for each message and the binding keys used to bind Queues to the Exchange. This exchange type is used to support the classic |
| publish/subscribe paradigm using a topic namespace as the addressing model to select and deliver messages across multiple |
| consumers based on a partial or full match on a topic pattern. |
| </para> |
| <para> |
| Binding and routing keys for this Exchange use a "." deliminator to seperate words representing different levels of the heirarchy, |
| with special meaning given to use of * and # as a word within a binding key such that a * matches any single word in a routing |
| key and # matches zero or more words, allowing a binding key to match many routing keys for published messages. For example, |
| a binding key of <emphasis>a.b.#</emphasis> would match the routing keys <emphasis>a.b</emphasis>, <emphasis>a.b.c</emphasis>, and |
| <emphasis>a.b.c.d</emphasis>, but not the routing key <emphasis>a.z</emphasis>.</para></listitem> |
| <listitem><para><emphasis>Fanout</emphasis>: routes messages to all queues bound to the exchange, regardless of the message's routing key. |
| </para></listitem> |
| <listitem><para><emphasis>Headers</emphasis>: routes messages to queues based on header properties within the AMQP message. |
| The message is passed to a queue if the header properties of the message satisfy header matching arguments table with which the queue was bound. |
| </para></listitem> |
| </itemizedlist> |
| </para> |
| <para>Also, Broker supports the concept of a Default Exchange to which all queues are bound using their name as a binding key.</para> |
| <para>Any number of exchanges of any type can be created on <emphasis>Virtual Host</emphasis>.</para> |
| <para>Exchange configuration is covered in <xref linkend="Java-Broker-Exchanges"/>.</para> |
| </section> |