ActiveMQ Artemis不遵守broker.xml中关于队列删除和队列配置的设置。

huangapple go评论45阅读模式
英文:

ActiveMQ Artemis does not respect broker.xml settings for queue deletion and queue configuration

问题

我正在运行ActiveMQ Artemis 2.28.0,使用以下显示的经纪人配置。我留下了我认为相关的内容(主要是默认设置)。

<configuration xmlns="urn:activemq"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xi="http://www.w3.org/2001/XInclude"
               xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
   <core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="urn:activemq:core ">

      <address-settings>
         <!-- 如果您在某些队列上定义了auto-create,则管理必须是auto-create -->
         <address-setting match="activemq.management#">
            <dead-letter-address>DLQ</dead-letter-address>
            <expiry-address>ExpiryQueue</expiry-address>
            <redelivery-delay>0</redelivery-delay>
            <!-- 仅使用global-max-size限制 -->
            <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>
         </address-setting>
         <!-- catch all的默认设置 -->
         <address-setting match="#">
            <dead-letter-address>DLQ</dead-letter-address>
            <expiry-address>ExpiryQueue</expiry-address>
            <redelivery-delay>0</redelivery-delay>
            <max-size-bytes>-1</max-size-bytes>
            <max-size-messages>-1</max-size-messages>
            <page-size-bytes>10M</page-size-bytes>
            <max-read-page-messages>-1</max-read-page-messages>
            <max-read-page-bytes>20M</max-read-page-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-delete-queues>false</auto-delete-queues>
            <auto-delete-addresses>false</auto-delete-addresses>
            <auto-delete-created-queues>false</auto-delete-created-queues>
            <default-exclusive-queue>false</default-exclusive-queue>
            <default-max-consumers>-1</default-max-consumers>
         </address-setting>
      </address-settings>

      <address-queue-scan-period>-1</address-queue-scan-period>

      <addresses>
         <address name="DLQ">
            <anycast>
               <queue name="DLQ" />
            </anycast>
         </address>
         <address name="ExpiryQueue">
            <anycast>
               <queue name="ExpiryQueue" />
            </anycast>
         </address>
      </addresses>
   </core>
</configuration>

使用这些设置,我有以下期望:

  • 需要时自动创建队列
  • 当消费者停止监听队列时,队列和地址仍然存在
  • 如果需要,多个消费者可以加入队列

然而,我观察到的行为如下:

  • 创建(多播)消费者时,队列会自动创建
  • 创建的队列的maxConsumerCount为1,尽管默认设置为-1
  • 当我关闭我的会话时,队列和地址都被删除,尽管队列的auto-delete-queues设置为false

作为可能的解决方法,我还添加了address-queue-scan-period的值,但这在观察到的行为中没有任何差异。

这是创建迹象,显示了不正确的maxConsumers值:

2023-06-15 15:56:05,251 DEBUG [org.apache.activemq.artemis.core.server.plugin.impl] AMQ843006: beforeCreateQueue called with queueConfig: QueueConfiguration [id=null, name=C7GN9YMV1P53I5PI.receiver, address=linda.acc.train.behaviour.12, routingType=MULTICAST, filterString=SubscriptionId='C7GN9YMV1P53I5PI' OR SubscriptionId IS NULL, durable=null, user=admin, maxConsumers=1, exclusive=false, groupRebalance=false, groupRebalancePauseDispatch=false, groupBuckets=-1, groupFirstKey=null, lastValue=false, lastValueKey=null, nonDestructive=false, purgeOnNoConsumers=false, enabled=true, consumersBeforeDispatch=0, delayBeforeDispatch=-1, consumerPriority=null, autoDelete=false, autoDeleteDelay=0, autoDeleteMessageCount=0, ringSize=-1, configurationManaged=null, temporary=null, autoCreateAddress=true, internal=null, transient=null, autoCreated=null]

当关闭消费者时,下面的日志指示队列和地址被销毁,这与我的设置不符:

2023-06-15 15:56:35,559 INFO  [org.apache.activemq.artemis.core.server.plugin.impl] AMQ841006: closed consumer ID: 0, with  consumer Session: 5ef8b4b4-0b84-11ee-be26-d6283bc2e653, failed: false
2023-06-15 15:56:35,568 DEBUG [org.apache.activemq.artemis.core

<details>
<summary>英文:</summary>

I&#39;m running ActiveMQ Artemis 2.28.0 with a broker config as shown below. I left the things in which I think are relevant (mainly default settings).

I am sure the file is actually used because if I disable auto-create-queues for example I do get errors as expected, but other settings just seem to be ignored in my use case.

```xml
&lt;configuration xmlns=&quot;urn:activemq&quot;
               xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
               xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot;
               xsi:schemaLocation=&quot;urn:activemq /schema/artemis-configuration.xsd&quot;&gt;
   &lt;core xmlns=&quot;urn:activemq:core&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;urn:activemq:core &quot;&gt;

      &lt;address-settings&gt;
         &lt;!-- if you define auto-create on certain queues, management has to be auto-create --&gt;
         &lt;address-setting match=&quot;activemq.management#&quot;&gt;
            &lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
            &lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
            &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
            &lt;!-- with -1 only the global-max-size is in use for limiting --&gt;
            &lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
            &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
            &lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
            &lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
            &lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
         &lt;/address-setting&gt;
         &lt;!--default for catch all--&gt;
         &lt;address-setting match=&quot;#&quot;&gt;
            &lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
            &lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
            &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
            &lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
            &lt;max-size-messages&gt;-1&lt;/max-size-messages&gt;
            &lt;page-size-bytes&gt;10M&lt;/page-size-bytes&gt;
            &lt;max-read-page-messages&gt;-1&lt;/max-read-page-messages&gt;
            &lt;max-read-page-bytes&gt;20M&lt;/max-read-page-bytes&gt;
            &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
            &lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
            &lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
            &lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
            &lt;auto-delete-queues&gt;false&lt;/auto-delete-queues&gt;
            &lt;auto-delete-addresses&gt;false&lt;/auto-delete-addresses&gt;

            &lt;auto-delete-created-queues&gt;false&lt;/auto-delete-created-queues&gt;
            &lt;default-exclusive-queue&gt;false&lt;/default-exclusive-queue&gt;
            &lt;default-max-consumers&gt;-1&lt;/default-max-consumers&gt;

         &lt;/address-setting&gt;
      &lt;/address-settings&gt;

      &lt;address-queue-scan-period&gt;-1&lt;/address-queue-scan-period&gt;

      &lt;addresses&gt;
         &lt;address name=&quot;DLQ&quot;&gt;
            &lt;anycast&gt;
               &lt;queue name=&quot;DLQ&quot; /&gt;
            &lt;/anycast&gt;
         &lt;/address&gt;
         &lt;address name=&quot;ExpiryQueue&quot;&gt;
            &lt;anycast&gt;
               &lt;queue name=&quot;ExpiryQueue&quot; /&gt;
            &lt;/anycast&gt;
         &lt;/address&gt;
      &lt;/addresses&gt;
   &lt;/core&gt;
&lt;/configuration&gt;

With these settings I have following expectations:

  • queues are auto-created when needed
  • when a consumer stops listening to a queue both the queue and the address still exists
  • more than one consumer can join the queue if necessary

However, the behaviour I observe is as follows:

  • when creating a (multicast) consumer the queue is automatically created
  • the created queue has a maxConsumerCount of 1 even though the default is set to -1
  • when I close my session both the queue and the address are deleted, even though the queue has auto-delete-queues set to false

As a possible workaround I also added the address-queue-scan-period value but this doesn't make a difference in the observed behaviour.

This is a trace of creation which shows the incorrect maxConsumers value

2023-06-15 15:56:05,251 DEBUG [org.apache.activemq.artemis.core.server.plugin.impl] AMQ843006: beforeCreateQueue called with queueConfig: QueueConfiguration [id=null, name=C7GN9YMV1P53I5PI.receiver, address=linda.acc.train.behaviour.12, routingType=MULTICAST, filterString=SubscriptionId=&#39;C7GN9YMV1P53I5PI&#39; OR SubscriptionId IS NULL, durable=null, user=admin, maxConsumers=1, exclusive=false, groupRebalance=false, groupRebalancePauseDispatch=false, groupBuckets=-1, groupFirstKey=null, lastValue=false, lastValueKey=null, nonDestructive=false, purgeOnNoConsumers=false, enabled=true, consumersBeforeDispatch=0, delayBeforeDispatch=-1, consumerPriority=null, autoDelete=false, autoDeleteDelay=0, autoDeleteMessageCount=0, ringSize=-1, configurationManaged=null, temporary=null, autoCreateAddress=true, internal=null, transient=null, autoCreated=null]

When the consumer is closed below log indicates the queue and the address is destroyed which does not match with my settings.

2023-06-15 15:56:35,559 INFO  [org.apache.activemq.artemis.core.server.plugin.impl] AMQ841006: closed consumer ID: 0, with  consumer Session: 5ef8b4b4-0b84-11ee-be26-d6283bc2e653, failed: false
2023-06-15 15:56:35,568 DEBUG [org.apache.activemq.artemis.core.server.plugin.impl] AMQ843007: beforeDestroyQueue called with queueName: C7GN9YMV1P53I5PI.receiver, session: ServerSessionImpl(), checkConsumerCount: true, removeConsumers: false, autoDeleteAddress: true

At this point I don't really know if I'm running against a bug or if I'm misunderstanding the setup parameters.

答案1

得分: 0

我相信你误解了自动地址和队列创建功能。自动地址和队列创建仅适用于在正常操作情况下_否则不会创建地址或队列_的情况下。例如,如果JMS生产者将消息发送到broker.xml中不存在的JMS队列,则根据默认设置,将创建相应的地址和任播队列,并将消息存储在该队列中。

也就是说,从技术上讲,在多播(即发布/订阅)用例中,无论broker.xml中的自动创建设置如何,队列都会自动创建。文档通常将这些队列称为“订阅队列”。例如,如果JMS消费者订阅了JMS主题,该主题的相应地址已在broker.xml中配置,则无论自动创建配置如何,都会自动创建用于消费者订阅的多播队列,因为订阅队列对于正常的多播语义是_必需的_。如果不自动创建订阅队列,那么您将不得不为每个订阅者手动在broker.xml中配置多播队列,这是不现实的。从历史上看,这种行为在没有任何其他地址和队列自动创建概念之前就存在了。

此外,无论default-* address-settings的配置如何,某些设置都会应用于订阅队列(例如,default-max-consumersdefault-exclusive)。这是由于特定订阅队列的性质。例如,在JMS中,订阅可以是共享的或非共享的,以及持久的或非持久的。非共享订阅队列的最大消费者数为1,因为它们永远不应该共享(即具有> 1个消费者)。

英文:

I believe you have misunderstood the automatic address & queue creation functionality. Automatic address & queue creation only applies in situations where the address or queue wouldn't be created otherwise for normal operation. For example if a JMS producer sent a message to a JMS queue that didn't already exist in broker.xml then with the default settings the corresponding address & anycast queue would be created and the message would be stored in that queue.

That said, technically speaking queues are automatically created in multicast (i.e. pub/sub) use-cases regardless of the auto-create settings in broker.xml. The documentation typically refers to these queues as "subscription queues." For example, if a JMS consumer subscribed to a JMS topic whose corresponding address was already configured in broker.xml then a multicast queue for the consumer's subscription would be created automatically regardless of the auto-creation configuration. This is because the subscription queue is required for normal multicast semantics. If subscription queues weren't automatically created then you would have to manually configure the multicast queue in broker.xml for every subscriber which is unrealistic. Historically speaking, this behavior existed long before there was any other notion of address & queue auto-creation.

Furthermore, certain settings are applied to subscription queues regardless of the configuration of the default-* address-settings (e.g. default-max-consumers, default-exclusive). This is due to the nature of the particular subscription queue. For example, in JMS subscriptions can be shared or unshared & durable or non-durable. Unshared subscription queues have a max-consumer count of 1 because they are never supposed to be shared (i.e. have > 1 consumer).

huangapple
  • 本文由 发表于 2023年6月16日 00:53:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483894.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定