ActiveMQ and maxPageSize

2019-02-26 16:25发布

问题:

I would like to set the maxPageSize to a larger number from its default 200.

This is how I set in the activemq.xml file:

<destinationPolicy>
            <policyMap>
              <policyEntries>
              ---
                <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb" maxPageSize="SOME_LARGE_NUMBER">
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

This change helps me get the number of messages in a queue using QueueBrowser.getEnumeration() as it returned 200 even if the number of messages in the queue were greater than 200.

Please see: http://docs.oracle.com/javaee/1.4/api/javax/jms/QueueBrowser.html for QueueBrowser.getEnumeration().

What is the side effect of changing the maxPageSize from 200 to say 1000? Does it affect the broker's performance anyway?

I am not seeing any documentation for this property other than "maximum number of persistent messages to page from store at a time" on this page:

http://activemq.apache.org/per-destination-policies.html

Thanks for your time!

回答1:

Max page size simply indicates the number of messages that will be loaded into memory, so the impact is.. that it will consume more memory.

Reading between the lines though, the reason that you are doing this is an anti-pattern. Queue browsing as part of an application is really a misuse of messaging - a message queue works best when treated as a queue. First in, first out. Not as an array that you scan to see whether a message has arrived.

You are much better off consuming each of the messages, and either:

  1. sorting them onto a bunch of other queues depending on their payload and then processing that second level of queues differently, or
  2. storing the payloads into a database and selecting based on the content.


标签: activemq