This is mostly the same code with the listener:
from json import dumps
from random import randint
from stomp import (Connection,
ConnectionListener)
import time
# Listener that consumes messages and display the priority of the received
message.
class PriorityTestListener(ConnectionListener):
def __init__(self,
conn):
# Used to ACK messages once they are processed.
self.conn = conn
def on_message(self,
frame):
# Called by the STOMP connection when a MESSAGE frame is received.
# Parameters: frame (Frame) - the stomp frame
# message is a stomp.utils.Frame with:
# message.cmd == "MESSAGE"
# message.headers == dict()
# message.body == str
message_id = frame.headers["message-id"]
subscription = int(frame.headers["subscription"])
priority = int(frame.headers["priority"])
print("Received message with id",
message_id,
"and priority",
priority,
".")
# Simulate long-running process.
time.sleep(1)
conn.ack(message_id,
subscription)
conn = Connection([("localhost", 61613)])
listener = PriorityTestListener(conn)
conn.set_listener("",
listener)
conn.connect(wait=True)
# First, stuff a number of low-priority messages into the queue.
for _ in range(250):
priority = randint(1,5)
conn.send("/queue/Priority Test",
dumps({}),
"application/json",
headers={"persistent": "true",
"priority": priority})
# Now start working off the queue.
conn.subscribe("/queue/Priority Test",
42,
ack="client-individual",
headers={"activemq.prefetchSize": 1})
# Now stuff a few high-priority message onto the queue.
# We would like for them to be processed immediately.
time.sleep(20)
for _ in range(10):
priority = 9
print("Adding a high priority message to the queue . . .")
conn.send("/queue/Priority Test",
dumps({}),
"application/json",
headers={"persistent": "true",
"priority": 9})
time.sleep(randint(5,10))
# Keep the process alive until the connection terminates.
try:
while conn.is_connected():
time.sleep(30)
except:
# Ctrl-C throws an exception
pass
print("Process complete.")
for _ in range(25):
priority = randint(1,9)
conn.send("/queue/Priority Test",
dumps({}),
"application/json",
headers={"persistent": "true",
"priority": 9})
UPDATE:
The issue only shows up iff the consumer is processing a LOT of messages on the
queue and a higher priority message arrives -- it doesn't recognize and consume
that new higher priority message until it finished consuming a dozen or so
lower priority messages. It's as if it has cached the messages it "plans" to
consume and processes those before grabbing the highest priority messages off
of the queue.
Why is this an issue you may ask? Because I am using the queue to pass long
running tasks to a server that can only process one task at a time. There are
currently thousands of low-priority messages in the queue, some of which take
several minutes to complete, and I would like to have new high-priority
messages processed right away.
If you run the code above and only stuff, say, 50 or 100 low priority messages
on the queue before peppering it with high priority messages it works as
advertised. But with 250 or more in the queue there is a delay . . . here is
the output (notice the delay before it picks up the first several high-priority
messages):
/usr/bin/python3.6 /pub/dev/flotsam/run_priority_message_test.py
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:3
and priority 5 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:4
and priority 5 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:5
and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:11 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:12 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:14 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:15 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:25 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:26 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:31 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:33 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:35 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:36 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:38 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:40 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:45 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:47 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:48 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:49 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:50 and priority 5 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:51 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:56 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:57 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:65 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:68 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:69 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:73 and priority 5 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:74 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:89 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:94 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:110 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:118 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:124 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:125 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:128 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:151 and priority 5 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:153 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:162 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:167 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:169 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:174 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:178 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:190 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:194 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:200 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:201 and priority 5 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:203 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:205 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:206 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:216 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:228 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:251 and priority 9 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:252 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:253 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:254 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:255 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:229 and priority 5 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:256 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:233 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:236 and priority 5 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:241 and priority 5 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:2
and priority 4 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:257 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:13 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:19 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:23 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:24 and priority 4 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:258 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:28 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:64 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:66 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:75 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:76 and priority 4 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:259 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:77 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:78 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:81 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:84 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:86 and priority 4 .
Adding a high priority message to the queue . . .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:260 and priority 9 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:88 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:91 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:93 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:95 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:97 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:99 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:104 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:108 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:114 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:121 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:131 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:142 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:145 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:146 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:147 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:157 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:160 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:163 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:164 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:173 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:176 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:177 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:186 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:187 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:193 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:209 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:212 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:214 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:215 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:219 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:220 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:225 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:232 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:246 and priority 4 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:249 and priority 4 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:1
and priority 3 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:6
and priority 3 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:8
and priority 3 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:9
and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:20 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:41 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:42 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:43 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:55 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:59 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:83 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:87 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:90 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:92 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:102 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:106 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:111 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:117 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:130 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:135 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:141 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:152 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:154 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:155 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:156 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:158 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:159 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:161 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:184 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:189 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:195 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:199 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:208 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:211 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:213 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:217 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:218 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:224 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:226 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:234 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:235 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:237 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:239 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:240 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:244 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:248 and priority 3 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:10 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:17 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:22 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:27 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:29 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:32 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:34 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:44 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:46 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:52 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:54 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:60 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:61 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:62 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:67 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:71 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:79 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:80 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:98 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:101 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:103 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:105 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:107 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:112 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:115 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:120 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:126 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:129 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:132 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:133 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:134 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:136 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:139 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:148 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:149 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:150 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:165 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:166 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:168 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:170 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:171 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:179 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:182 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:185 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:188 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:196 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:207 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:210 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:222 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:223 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:227 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:230 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:242 and priority 2 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:243 and priority 2 .
Received message with id ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:7
and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:16 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:18 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:21 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:30 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:37 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:39 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:53 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:58 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:63 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:70 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:72 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:82 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:85 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:96 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:100 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:109 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:113 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:116 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:119 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:122 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:123 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:127 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:137 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:138 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:140 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:143 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:144 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:172 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:175 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:180 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:181 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:183 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:191 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:192 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:197 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:198 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:202 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:204 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:221 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:231 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:238 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:245 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:247 and priority 1 .
Received message with id
ID:Spark01.msic.ic.gov-36082-1654522010467-3:23:-1:1:250 and priority 1 .
Process complete.
Process finished with exit code 0
________________________________
From: Justin Bertram <[email protected]>
Sent: Tuesday, June 7, 2022 4:46 PM
To: [email protected] <[email protected]>
Subject: [External] - Re: Stomp/Python Message Priority Seems To Be Ignored
CAUTION: This email originated from outside of the organization. Do not click
links or open attachments unless you recognize the sender and know the content
is safe.
Can you paste the consumer code as well? Is the consumer running while the
messages are being sent or do you send all the messages and then start the
consumer?
Justin
On Tue, Jun 7, 2022 at 12:11 PM Richard Bergmann
<[email protected]> 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="https://usg02.safelinks.protection.office365.us/?url=http%3A%2F%2Factivemq.apache.org%2Fschema%2Fcore&data=05%7C01%7CRBERGMANN%40colsa.com%7C531ad58d766e430b059d08da48c6dfe1%7C9821086b78824b43a5edb1e979bee31f%7C1%7C0%7C637902317189927363%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=YVX2so%2Fm9Vhr1f4N9Pt%2FRMRR1kX4ndNIZ8YwrdqTuDo%3D&reserved=0"
> 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:
> https://usg02.safelinks.protection.office365.us/?url=http%3A%2F%2Factivemq.apache.org%2Fslow-consumer-handling.html&data=05%7C01%7CRBERGMANN%40colsa.com%7C531ad58d766e430b059d08da48c6dfe1%7C9821086b78824b43a5edb1e979bee31f%7C1%7C0%7C637902317189927363%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=B80zy76K9Xzme23WUG55SX27hOI1WYLchrFMRFFFRZI%3D&reserved=0
> -->
> <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
>
________________________________
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