4.9.5. Queue Threshold Alerts (Edge-triggered)


In MRG 3, Queue Threshold alerts are edge-triggered. Thresholds are configured per-queue and are:
  • qpid.alert_count_up - upper threshold (messages)
  • qpid.alert_size_up - upper threshold (bytes)
  • qpid.alert_count_down - lower threshold (messages)
  • qpid.alert_size_down - lower threshold (bytes)
By default, the upward threshold is set to the global threshold ratio multiplied by the maximum size/count of the queue. The global threshold ratio can be specified using the --default-event-threshold-ratio command line option, otherwise it defaults to 80%.
By default, the downward threshold is set to one half of the default upward threshold.
Note: The upper and lower thresholds should have a gap between them to limit event rates.
Events

There are two different events:

Threshold crossed increasing
The increasing event is raised when the queue depth goes from (upper-threshold - 1) to upper-threshold and the increasing event flag is not already set. When an increasing event occurs the increasing event flag is set. The increasing event flag must be cleared (by a decreasing event) before further increasing events will be raised. This prevents multiple retriggering of this event by fluctuation of queue depth around the upper-threshold.
Threshold crossed decreasing
The decreasing event is raised when the increasing event flag is set and the queue depth goes from (lower-threshold + 1) to lower-threshold. The decreasing event clears the increasing event flag, allowing further increasing events to be triggered and preventing multiple retriggering of this event by fluctuation of queue depth around the lower-threshold.
The events are sent via the QMF framework. You can subscribe to the event messages by listening to the addresses:
  • qmf.default.topic/agent.ind.event.org_apache_qpid_broker.queueThresholdCrossedUpward.#
  • qmf.default.topic/agent.ind.event.org_apache_qpid_broker.queueThresholdCrossedDownward.#
Events are sent as map messages:
qmf::org::apache::qpid::broker::EventQueueThresholdCrossedUpward(name, count, size)
qmf::org::apache::qpid::broker::EventQueueThresholdCrossedDownward(name, count, size)
The following code demonstrates subscribing to and consuming threshold event messages:

Window One

Python
import sys
from qpid.messaging import *
conn = Connection.establish("localhost:5672")
session = conn.session()
rcv = session.receiver("qmf.default.topic/agent.ind.event.org_apache_qpid_broker.queueThresholdCrossedUpward.#")
while True:
   event = rcv.fetch()
   print "Threshold exceeded on queue %s" % event.content[0]["_values"]["qName"]
   print "at a depth of %s messages, %s bytes" % (event.content[0]["_values"]["msgDepth"], event.content[0]["_values"]["byteDepth"])
   session.acknowledge()

Window Two

Python
import sys
from qpid.messaging import *
connection = Connection.establish("localhost:5672")
session = connection.session()
rcv = session.receiver("threshold-queue; {create:always, node:{x-declare:{auto-delete:True, arguments:{'qpid.alert_count_down':1,'qpid.alert_count_up':3}}}}")
snd = session.sender("threshold-queue")

snd.send("Message1")
snd.send("Message2")
snd.send("Message3")
rcv.fetch()
rcv.fetch()
rcv.fetch()
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.