Consider changing DisruptorEventQueue.enqueue() to avoid possibility of blocking

This repository was archived by the owner on Dec 23, 2023. It is now read-only.

This repository was archived by the owner on Dec 23, 2023. It is now read-only.

@jmullins

Description

Does it make sense to change DisruptorEventQueue.enqueue() to use RingBuffer.tryNext() instead of RingBuffer.next() to avoid possibly blocking in the case the producers overrun the consumer due to load or a future bug in the consumer?

In all of our use-cases our preference would be to drop the metrics rather than block.

DisruptorEnqueuer enqueuer =
new DisruptorEnqueuer() {
@Override
public void enqueue(Entry entry) {
long sequence = ringBuffer.next();
try {
DisruptorEvent event = ringBuffer.get(sequence);
event.setEntry(entry);
} finally {
ringBuffer.publish(sequence);
}
}
};