/** * The caller of this method requires synchronized on the queue. * I'm not going to add synchronized to this method just for a precaution, * as I'm not 100% sure this won't cause any extra runtime. * * @param ref */ private void internalAddHead(final MessageReference ref) { queueMemorySize.addAndGet(ref.getMessageMemoryEstimate()); pendingMetrics.incrementMetrics(ref); refAdded(ref); int priority = getPriority(ref); messageReferences.addHead(ref, priority); }