chroniclechronicle-queue

Queue depth monitoring


Is there a recommended performant way to monitor the depth of a chronicle-queue (the number of messages yet to be read)

I am thinking I can compare index() at current location with the index after moving to end, but this may be too costly in terms of performance. Potentially I can perform this in a background "monitoring thread"


Solution

  • You can use a "named tailer", which can be monitored in another thread/process. This can be compared to the end of the queue. If you do this periodically say every 1 ms or more, the overhead is low.

    Alternatively, the reader could do this monitoring by holding a tailer at toEnd() and comparing this to the one it is reading.