Remember that if you're using KahaDB there's really just three priorities[1].
We tend to stick with just 0, 4 and 9 for simplicity. BR, - Simon 1, <https://activemq.apache.org/how-can-i-support-priority-queues> On Tue, 2022-06-07 at 19:10:56 +0200, Richard Bergmann wrote: > Broker > Name localhost > Version 5.16.0 > ID ID:xxxxxxxxx-36082-1654522010467-0:1 > Uptime 1 day 3 hours > Store percent used 0 > Memory percent used 0 > Temp percent used 0 > > Out of necessity I have a single consumer of a queue (work needs to be > completed serially), but I need to have some messages processed before > others, i.e., in priority order. > > I have researched the documentation and my activmq.xml file contains: > > <broker xmlns="http://activemq.apache.org/schema/core" > brokerName="localhost" > dataDirectory="${activemq.data}"> > <destinationPolicy> > <policyMap> > <policyEntries> > <policyEntry queue=">" prioritizedMessages="true" useCache="false" > expireMessagesPeriod="0" queuePrefetch="1"/> > <policyEntry topic=">" > > <!-- > The constantPendingMessageLimitStrategy is used to prevent > slow topic consumers to block producers and affect other > consumers > by limiting the number of messages that are retained > For more information, see: > http://activemq.apache.org/slow-consumer-handling.html > --> > <pendingMessageLimitStrategy> > <constantPendingMessageLimitStrategy limit="1000"/> > </pendingMessageLimitStrategy> > </policyEntry> > </policyEntries> > </policyMap> > </destinationPolicy> > > If I run this Python code: > > from json import dumps > from random import randint > from stomp import Connection > > > conn = Connection([("localhost", 61613)]) > conn.connect() > > for _ in range(25): > priority = randint(1,9) > conn.send("/queue/Priority Test", > dumps({}), > "application/json", > headers={"persistent": "true", > "priority": priority}) > > The messages appear in the queue (and are therefore consumed from the queue) > in the order they arrived, not priority order. > > Of course, if I manually sort the messages using the web interface > (http://localhost:8161/admin/browse.jsp?JMSDestination=Queue+Name<http://localhost:8161/admin/browse.jsp?JMSDestination=Queue+Name+>) > the messages will be consumed in the desired order, but this is not a > workable solution. > > Am I missing somehing? > ________________________________ > The information contained in this e-mail and any attachments from COLSA > Corporation may contain company sensitive and/or proprietary information, and > is intended only for the named recipient to whom it was originally addressed. > If you are not the intended recipient, any disclosure, distribution, or > copying of this e-mail or its attachments is strictly prohibited. If you have > received this e-mail in error, please notify the sender immediately by return > e-mail and permanently delete the e-mail and any attachments. > > > COLSA Proprietary