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

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

T ReadOne(
	long sequence


Type: SystemInt64
the sequence of the item to read.

Return Value

Type: T
the read item

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.

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();
String item = ringbuffer.ReadOne(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