activemq artemis address 详细配置实例
默认配置:
<address-setting match="#">
<dead-letter-address>DLQ</dead-letter-address>
<expiry-address>ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<!-- with -1 only the global-max-size is in use for limiting -->
<max-size-bytes>-1</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<auto-create-queues>true</auto-create-queues>
<auto-create-addresses>true</auto-create-addresses>
<auto-create-jms-queues>true</auto-create-jms-queues>
<auto-create-jms-topics>true</auto-create-jms-topics>
<!--min-expiry-delay>86400000</min-expiry-delay> zfr
<max-expiry-delay>102400000</max-expiry-delay-->
<expiry-delay>86400000</expiry-delay>
<auto-create-expiry-resources>true</auto-create-expiry-resources>
<expiry-queue-prefix></expiry-queue-prefix><!-- override the default-->
<expiry-queue-suffix>.EXP</expiry-queue-suffix>
<auto-delete-queues>true</auto-delete-queues>
<auto-delete-created-queues>true</auto-delete-created-queues>
<auto-delete-queues-delay>86400000</auto-delete-queues-delay>
<auto-delete-queues-message-count>0</auto-delete-queues-message-count>
<config-delete-queues>FORCE</config-delete-queues>
<auto-delete-addresses>true</auto-delete-addresses>
<auto-delete-addresses-delay>86400000</auto-delete-addresses-delay>
<config-delete-addresses>FORCE</config-delete-addresses>
</address-setting>
Configuring Addresses and Queues via Address Settings
There are some attributes that are defined against an address wildcard rather than a specific address/queue. Here an example of anaddress-setting
entry that would be found in thebroker.xml
file.
<address-settings>
<address-setting match="order.foo">
<dead-letter-address>DLA</dead-letter-address>
<auto-create-dead-letter-resources>false</auto-create-dead-letter-resources>
<dead-letter-queue-prefix>DLQ.</dead-letter-queue-prefix>
<dead-letter-queue-suffix></dead-letter-queue-suffix>
<expiry-address>ExpiryQueue</expiry-address>
<auto-create-expiry-resources>false</auto-create-expiry-resources>
<expiry-queue-prefix>EXP.</expiry-queue-prefix>
<expiry-queue-suffix></expiry-queue-suffix>
<expiry-delay>123</expiry-delay>
<redelivery-delay>5000</redelivery-delay>
<redelivery-delay-multiplier>1.0</redelivery-delay-multiplier>
<redelivery-collision-avoidance-factor>0.0</redelivery-collision-avoidance-factor>
<max-redelivery-delay>10000</max-redelivery-delay>
<max-delivery-attempts>3</max-delivery-attempts>
<max-size-bytes>100000</max-size-bytes>
<max-size-bytes-reject-threshold>-1</max-size-bytes-reject-threshold>
<page-size-bytes>20000</page-size-bytes>
<page-max-cache-size></page-max-cache-size>
<address-full-policy>PAGE</address-full-policy>
<message-counter-history-day-limit></message-counter-history-day-limit>
<last-value-queue>true</last-value-queue> <!-- deprecated! see default-last-value-queue -->
<default-last-value-queue>false</default-last-value-queue>
<default-non-destructive>false</default-non-destructive>
<default-exclusive-queue>false</default-exclusive-queue>
<default-consumers-before-dispatch>0</default-consumers-before-dispatch>
<default-delay-before-dispatch>-1</default-delay-before-dispatch>
<redistribution-delay>0</redistribution-delay>
<send-to-dla-on-no-route>true</send-to-dla-on-no-route>
<slow-consumer-threshold>-1</slow-consumer-threshold>
<slow-consumer-policy>NOTIFY</slow-consumer-policy>
<slow-consumer-check-period>5</slow-consumer-check-period>
<auto-create-jms-queues>true</auto-create-jms-queues> <!-- deprecated! see auto-create-queues -->
<auto-delete-jms-queues>true</auto-delete-jms-queues> <!-- deprecated! see auto-delete-queues -->
<auto-create-jms-topics>true</auto-create-jms-topics> <!-- deprecated! see auto-create-addresses -->
<auto-delete-jms-topics>true</auto-delete-jms-topics> <!-- deprecated! see auto-delete-addresses -->
<auto-create-queues>true</auto-create-queues>
<auto-delete-queues>true</auto-delete-queues>
<auto-delete-created-queues>false</auto-delete-created-queues>
<auto-delete-queues-delay>0</auto-delete-queues-delay>
<auto-delete-queues-message-count>0</auto-delete-queues-message-count>
<config-delete-queues>OFF</config-delete-queues>
<auto-create-addresses>true</auto-create-addresses>
<auto-delete-addresses>true</auto-delete-addresses>
<auto-delete-addresses-delay>0</auto-delete-addresses-delay>
<config-delete-addresses>OFF</config-delete-addresses>
<management-browse-page-size>200</management-browse-page-size>
<default-purge-on-no-consumers>false</default-purge-on-no-consumers>
<default-max-consumers>-1</default-max-consumers>
<default-queue-routing-type></default-queue-routing-type>
<default-address-routing-type></default-address-routing-type>
<default-ring-size>-1</default-ring-size>
<retroactive-message-count>0</retroactive-message-count>
<enable-metrics>true</enable-metrics>
</address-setting>
</address-settings>
The idea with address settings, is you can provide a block of settings which will be applied against any addresses that match the string in thematch
attribute. In the above example the settings would only be applied to the address "order.foo" address but you can also usewildcardsto apply settings.
For example, if you used thematch
stringqueue.#
the settings would be applied to all addresses which start withqueue.
The meaning of the specific settings are explained fully throughout the user manual, however here is a brief description with a link to the appropriate chapter if available.
dead-letter-address
is the address to which messages are sent when they exceedmax-delivery-attempts
. If no address is defined here then such messages will simply be discarded. Read more aboutundelivered messages.
auto-create-dead-letter-resources
determines whether or not the broker will automatically create the defineddead-letter-address
and a corresponding dead-letter queue when a message is undeliverable. Read more in the chapter aboutundelivered messages.
dead-letter-queue-prefix
defines the prefix used for automatically created dead-letter queues. Read more in the chapter aboutundelivered messages.
dead-letter-queue-suffix
defines the suffix used for automatically created dead-letter queues. Read more in the chapter aboutundelivered messages.
expiry-address
defines where to send a message that has expired. If no address is defined here then such messages will simply be discarded. Read more aboutmessage expiry.
auto-create-expiry-resources
determines whether or not the broker will automatically create the definedexpiry-address
and a corresponding expiry queue when a message expired. Read more in the chapter aboutundelivered messages.
expiry-queue-prefix
defines the prefix used for automatically created expiry queues. Read more in the chapter aboutmessage expiry.
expiry-queue-suffix
defines the suffix used for automatically created expiry queues. Read more in the chapter aboutmessage expiry.
expiry-delay
defines the expiration time that will be used for messages which are using the default expiration time (i.e. 0). For example, ifexpiry-delay
is set to "10" and a message which is using the default expiration time (i.e. 0) arrives then its expiration time of "0" will be changed to "10." However, if a message which is using an expiration time of "20" arrives then its expiration time will remain unchanged. Settingexpiry-delay
to "-1" will disable this feature. The default is "-1". Read more aboutmessage expiry.
max-delivery-attempts
defines how many time a cancelled message can be redelivered before sending to thedead-letter-address
. Read more aboutundelivered messages.
redelivery-delay
defines how long to wait before attempting redelivery of a cancelled message. Default is0
. Read more aboutundelivered messages.
redelivery-delay-multiplier
defines the number by which theredelivery-delay
will be multiplied on each subsequent redelivery attempt. Default is1.0
. Read more aboutundelivered messages.
redelivery-collision-avoidance-factor
defines an additional factor used to calculate an adjustment to theredelivery-delay
(up or down). Default is0.0
. Valid values are between 0.0 and 1.0. Read more aboutundelivered messages.
max-size-bytes
,page-size-bytes
, &page-max-cache-size
are used to configure paging on an address. This is explainedhere.
max-size-bytes-reject-threshold
is used with the address fullBLOCK
policy, the maximum size (in bytes) an address can reach before messages start getting rejected. Works in combination withmax-size-bytes
for AMQP clients only. Default is-1
(i.e. no limit).
address-full-policy
. This attribute can have one of the following values:PAGE
,DROP
,FAIL
orBLOCK
and determines what happens when an address wheremax-size-bytes
is specified becomes full. The default value isPAGE
. If the value isPAGE
then further messages will be paged to disk. If the value isDROP
then further messages will be silently dropped. If the value isFAIL
then further messages will be dropped and an exception will be thrown on the client-side. If the value isBLOCK
then client message producers will block when they try and send further messages. See theFlow ControlandPagingchapters for more info.
message-counter-history-day-limit
is the number of days to keep message counter history for this address assuming thatmessage-counter-enabled
istrue
. Default is0
.
last-value-queue
isdeprecated. Seedefault-last-value-queue
. It defines whether a queue only uses last values or not. Default isfalse
. Read more aboutlast value queues.
default-last-value-queue
defines whether a queue only uses last values or not. Default isfalse
. This value can be overridden at the queue level using thelast-value
boolean. Read more aboutlast value queues.
default-exclusive-queue
defines whether a queue will serve only a single consumer. Default isfalse
. This value can be overridden at the queue level using theexclusive
boolean. Read more aboutexclusive queues.
default-consumers-before-dispatch
defines the number of consumers needed on a queue bound to the matching address before messages will be dispatched to those consumers. Default is0
. This value can be overridden at the queue level using theconsumers-before-dispatch
boolean. This behavior can be tuned usingdelay-before-dispatch
on the queue itself or by using thedefault-delay-before-dispatch
address-setting.
default-delay-before-dispatch
defines the number of milliseconds the broker will wait for the configured number of consumers to connect to the matching queue before it will begin to dispatch messages. Default is-1
(wait forever).
redistribution-delay
defines how long to wait when the last consumer is closed on a queue before redistributing any messages. Read more aboutclusters.
send-to-dla-on-no-route
. If a message is sent to an address, but the server does not route it to any queues (e.g. there might be no queues bound to that address, or none of the queues have filters that match) then normally that message would be discarded. However, if this parameter istrue
then such a message will instead be sent to thedead-letter-address
(DLA) for that address, if it exists.
slow-consumer-threshold
. The minimum rate of message consumption allowed before a consumer is considered "slow." Measured in messages-per-second. Default is-1
(i.e. disabled); any other valid value must be greater than 0. Read more aboutslow consumers.
slow-consumer-policy
. What should happen when a slow consumer is detected.KILL
will kill the consumer's connection (which will obviously impact any other client threads using that same connection).NOTIFY
will send a CONSUMER_SLOW management notification which an application could receive and take action with. Read more aboutslow consumers.
slow-consumer-check-period
. How often to check for slow consumers on a particular queue. Measured in_seconds_. Default is5
. Read more aboutslow consumers.
auto-create-jms-queues
isdeprecated. Seeauto-create-queues
. Whether or not the broker should automatically create a JMS queue when a JMS message is sent to a queue whose name fits the addressmatch
(remember, a JMS queue is just a core queue which has the same address and queue name) or a JMS consumer tries to connect to a queue whose name fits the addressmatch
. Queues which are auto-created are durable, non-temporary, and non-transient. Default istrue
.
auto-delete-jms-queues
isdeprecated. Seeauto-delete-queues
. Whether or not the broker should automatically delete auto-created JMS queues when they have both 0 consumers and 0 messages. Default istrue
.
auto-create-jms-topics
isdeprecated. Seeauto-create-addresses
. Whether or not the broker should automatically create a JMS topic when a JMS message is sent to a topic whose name fits the addressmatch
(remember, a JMS topic is just a core address which has one or more core queues mapped to it) or a JMS consumer tries to subscribe to a topic whose name fits the addressmatch
. Default istrue
.
auto-delete-jms-topics
isdeprecated. Seeauto-delete-addresses
. Whether or not the broker should automatically delete auto-created JMS topics once the last subscription on the topic has been closed. Default istrue
.
auto-create-queues
. Whether or not the broker should automatically create a queue when a message is sent or a consumer tries to connect to a queue whose name fits the addressmatch
. Queues which are auto-created are durable, non-temporary, and non-transient. Default istrue
.**Note:**automatic queue creation does_not_work for the core client. The core API is a low-level API and is not meant to have such automation.
auto-delete-queues
. Whether or not the broker should automatically delete auto-created queues when they have both 0 consumers and the message count is less than or equal toauto-delete-queues-message-count
. Default istrue
.
auto-delete-created-queues
. Whether or not the broker should automatically delete created queues when they have both 0 consumers and the message count is less than or equal toauto-delete-queues-message-count
. Default isfalse
.
auto-delete-queues-delay
. How long to wait (in milliseconds) before deleting auto-created queues after the queue has 0 consumers and the message count is less than or equal toauto-delete-queues-message-count
. Default is0
(delete immediately). The broker'saddress-queue-scan-period
controls how often (in milliseconds) queues are scanned for potential deletion. Use-1
to disable scanning. The default scan value is30000
.
auto-delete-queues-message-count
. The message count that the queue must be less than or equal to before deleting auto-created queues. To disable message count check-1
can be set. Default is0
(empty queue).
**Note:**the above auto-delete address settings can also be configured individually at the queue level when a client auto creates the queue.
For Core API it is exposed in createQueue methods.
For Core JMS you can set it using the destination queue attributesmy.destination?auto-delete=true&auto-delete-delay=120000&auto-delete-message-count=-1
config-delete-queues
. How the broker should handle queues deleted on config reload, by delete policy:OFF
orFORCE
. Default isOFF
. Read more aboutconfiguration reload.
auto-create-addresses
. Whether or not the broker should automatically create an address when a message is sent to or a consumer tries to consume from a queue which is mapped to an address whose name fits the addressmatch
. Default istrue
.**Note:**automatic address creation does_not_work for the core client. The core API is a low-level API and is not meant to have such automation.
auto-delete-addresses
. Whether or not the broker should automatically delete auto-created addresses once the address no longer has any queues. Default istrue
.
auto-delete-addresses-delay
. How long to wait (in milliseconds) before deleting auto-created addresses after they no longer have any queues. Default is0
(delete immediately). The broker'saddress-queue-scan-period
controls how often (in milliseconds) addresses are scanned for potential deletion. Use-1
to disable scanning. The default scan value is30000
.
config-delete-addresses
. How the broker should handle addresses deleted on config reload, by delete policy:OFF
orFORCE
. Default isOFF
. Read more aboutconfiguration reload.
management-browse-page-size
is the number of messages a management resource can browse. This is relevant for the "browse" management method exposed on the queue control. Default is200
.
default-purge-on-no-consumers
defines a queue's defaultpurge-on-no-consumers
setting if none is provided on the queue itself. Default isfalse
. This value can be overridden at the queue level using thepurge-on-no-consumers
boolean. Read more aboutthis functionality.
default-max-consumers
defines a queue's defaultmax-consumers
setting if none is provided on the queue itself. Default is-1
(i.e. no limit). This value can be overridden at the queue level using themax-consumers
boolean. Read more aboutthis functionality.
default-queue-routing-type
defines the routing-type for an auto-created queue if the broker is unable to determine the routing-type based on the client and/or protocol semantics. Default isMULTICAST
. Read more aboutrouting types.
default-address-routing-type
defines the routing-type for an auto-created address if the broker is unable to determine the routing-type based on the client and/or protocol semantics. Default isMULTICAST
. Read more aboutrouting types.
default-consumer-window-size
defines the defaultconsumerWindowSize
value for aCORE
protocol consumer, if not defined the default will be set to 1 MiB (1024 * 1024 bytes). The consumer will use this value as the window size if the value is not set on the client. Read more aboutflow control.
default-ring-size
defines the defaultring-size
value for any matching queue which doesn't havering-size
explicitly defined. If not defined the default will be set to -1. Read more aboutring queues.
retroactive-message-count
defines the number of messages to preserve for future queues created on the matching address. Defaults to 0. Read more aboutretroactive addresses.
enable-metrics
determines whether or not metrics will be published to any configured metrics plugin for the matching address. Default istrue
. Read more aboutmetrics.