use of com.hazelcast.ringbuffer.StaleSequenceException in project hazelcast by hazelcast.
the class ReliableMessageListenerRunner method onFailure.
// This method is called from the provided executor.
@Override
public void onFailure(Throwable t) {
if (cancelled) {
return;
}
if (t instanceof StaleSequenceException) {
StaleSequenceException staleSequenceException = (StaleSequenceException) t;
if (listener.isLossTolerant()) {
if (logger.isFinestEnabled()) {
logger.finest("MessageListener " + listener + " on topic: " + topicName + " ran into a stale sequence. " + "Jumping from oldSequence: " + sequence + " to sequence: " + staleSequenceException.getHeadSeq());
}
sequence = staleSequenceException.getHeadSeq();
next();
return;
}
logger.warning("Terminating MessageListener:" + listener + " on topic: " + topicName + ". " + "Reason: The listener was too slow or the retention period of the message has been violated. " + "head: " + staleSequenceException.getHeadSeq() + " sequence:" + sequence);
} else if (t instanceof HazelcastInstanceNotActiveException) {
if (logger.isFinestEnabled()) {
logger.finest("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + " Reason: HazelcastInstance is shutting down");
}
} else if (t instanceof DistributedObjectDestroyedException) {
if (logger.isFinestEnabled()) {
logger.finest("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + "Reason: Topic is destroyed");
}
} else {
logger.warning("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + "Reason: Unhandled exception, message: " + t.getMessage(), t);
}
cancel();
}
use of com.hazelcast.ringbuffer.StaleSequenceException in project hazelcast by hazelcast.
the class RingbufferAbstractTest method readOne_whenBeforeHead_thenStaleSequenceException.
@Test
public void readOne_whenBeforeHead_thenStaleSequenceException() throws Exception {
RingbufferConfig ringbufferConfig = config.getRingbufferConfig(ringbuffer.getName());
for (int k = 0; k < ringbufferConfig.getCapacity() * 2; k++) {
ringbuffer.add("foo");
}
long headSeq = ringbuffer.headSequence();
try {
ringbuffer.readOne(headSeq - 1);
fail();
} catch (StaleSequenceException expected) {
assertEquals(headSeq, expected.getHeadSeq());
}
}
Aggregations