이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 5. Message Addresses and Queues
AMQ 7 introduces a new, flexible addressing model that enables you to define standard messaging patterns that work for any messaging protocol. Therefore, the process for configuring queues and topic-like behavior has changed significantly.
5.1. Addressing Changes
AMQ 6 implemented JMS concepts such as queues, topics, and durable subscriptions as directly-configurable destinations.
Example: Default Queue and Topic Configuration in AMQ 6
<destinations> <queue physicalName="my-queue" /> <topic physicalName="my-topic" /> </destinations>
AMQ Broker 7 uses addresses, routing types, and queues to achieve queue and topic-like behavior. An address represents a messaging endpoint. Queues are associated with addresses. A routing type defines how messages are distributed to the queues associated with an address. There are two routing types: Anycast distributes messages to a single queue within the matching address, and Multicast distributes messages to every queue associated with the address.
By associating queues with addresses and routing types, you can implement a variety of messaging patterns, such as point-to-point (queues) and publish-subscribe (topic-like).
Example: Point-to-Point Address Configuration in AMQ Broker 7
In this example, when the broker receives a message on address.foo
, the message will be routed to my-queue
. If multiple anycast queues are associated with the address, the messages are distributed evenly across the queues.
<address name="address.foo"> <anycast> <queue name="my-queue"/> </anycast> </address>
Example: Publish-Subscribe Address Configuration in AMQ Broker 7
In this example, when the broker receives a message on topic.foo
, a copy of the message will be routed to both my-topic-1
and my-topic-2
.
<address name="topic.foo"> <multicast> <queue name="my-topic-1"/> <queue name="my-topic-2"/> </multicast> </address>
Related Information
- For full details about the addressing model in AMQ Broker 7, see Configuring addresses and queues in Configuring AMQ Broker.
5.2. How Addressing is Configured
You use the BROKER_INSTANCE_DIR/etc/broker.xml
configuration file to configure addresses and queues for your broker instance.
The broker.xml
configuration file contains the following default addressing configuration in the <addresses>
section. There are default entries for the Dead Letter Queue (DLQ
) and Expiry Queue (ExpiryQueue
):
<addresses> <address name="DLQ"> <anycast> <queue name="DLQ" /> </anycast> </address> <address name="ExpiryQueue"> <anycast> <queue name="ExpiryQueue" /> </anycast> </address> </addresses>
You can configure addressing for your broker instance by using any of the following methods:
Method | Description |
---|---|
Manually configure an address | You define the routing types and queues that the broker should use when receiving a message on the address. You can configure an address in the following ways:
|
Configure the broker to create addresses automatically | You specify an address prefix and routing type for which addresses you want to be created automatically. When the broker receives a message on an address that matches the prefix, the address and routing type will be created automatically. You can also specify that the address be deleted automatically when all of its queues have been deleted, and that its queues be deleted automatically when they have no consumers or messages. For more information, see Configuring automatic creation and deletion of addresses and queues in Configuring AMQ Broker. |