IRingbufferTReadOne Method Hazelcast .Net Client Class Library
Reads one item from the Ringbuffer.

Namespace: Hazelcast.Core
Assembly: Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.8.1
Syntax

T ReadOne(
	long sequence
)

Parameters

sequence
Type: SystemInt64
the sequence of the item to read.

Return Value

Type: T
the read item
Exceptions

ExceptionCondition
StaleSequenceException if the sequence is smaller then HeadSequence . Because a Ringbuffer won't store all event indefinitely, it can be that the data for the given sequence doesn't exist anymore and the StaleSequenceException is thrown. It is up to the caller to deal with this particular situation, e.g. throw an Exception or restart from the last known head. That is why the StaleSequenceException contains the last known head.
ArgumentException if sequence is smaller than 0 or larger than TailSequence +1.
Exceptionif the call is interrupted while blocking.
Remarks

Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an item is added. This means that the ringbuffer can be processed using the following idiom:
Ringbuffer<String> ringbuffer = hz.GetRingbuffer("rb");
long seq = ringbuffer.HeadSequence();
while(true){
String item = ringbuffer.ReadOne(seq);
seq++;
... process item
}
This method is not destructive unlike e.g. a queue.take. So the same item can be read by multiple readers or it can be read multiple times by the same reader. Currently it isn't possible to control how long this call is going to block. In the future we could add e.g. tryReadOne(long sequence, long timeout, TimeUnit unit).
See Also

Reference