public abstract class MessageRunner<E> extends Object implements ExecutionCallback<ReadResultSet<ReliableTopicMessage>>
ExecutionCallback
that will try to read an
item from the ringbuffer or blocks if no item is available. All data
that are read is pushed into the MessageListener
.
It is a self-perpetuating stream of async calls.
The runner keeps track of the sequence.Modifier and Type | Field and Description |
---|---|
protected ReliableMessageListener<E> |
listener |
protected ILogger |
logger |
protected Ringbuffer<ReliableTopicMessage> |
ringbuffer |
protected long |
sequence |
protected String |
topicName |
Constructor and Description |
---|
MessageRunner(String id,
ReliableMessageListener<E> listener,
Ringbuffer<ReliableTopicMessage> ringbuffer,
String topicName,
int batchSze,
SerializationService serializationService,
Executor executor,
ConcurrentMap<String,MessageRunner<E>> runnersMap,
ILogger logger) |
Modifier and Type | Method and Description |
---|---|
protected abstract Throwable |
adjustThrowable(Throwable t)
Needed because client / server behaviour is different on onFailure call
|
void |
cancel() |
protected abstract long |
getHeadSequence(StaleSequenceException staleSequenceException) |
protected abstract Member |
getMember(ReliableTopicMessage m) |
protected boolean |
handleInternalException(Throwable t) |
boolean |
isCancelled() |
void |
next() |
void |
onFailure(Throwable t)
Called when an execution is completed with an error.
|
void |
onResponse(ReadResultSet<ReliableTopicMessage> result)
Called when an execution is completed successfully.
|
protected abstract void |
updateStatistics() |
protected final Ringbuffer<ReliableTopicMessage> ringbuffer
protected final ILogger logger
protected final ReliableMessageListener<E> listener
protected final String topicName
protected long sequence
public MessageRunner(String id, ReliableMessageListener<E> listener, Ringbuffer<ReliableTopicMessage> ringbuffer, String topicName, int batchSze, SerializationService serializationService, Executor executor, ConcurrentMap<String,MessageRunner<E>> runnersMap, ILogger logger)
public void next()
public void onResponse(ReadResultSet<ReliableTopicMessage> result)
ExecutionCallback
onResponse
in interface ExecutionCallback<ReadResultSet<ReliableTopicMessage>>
result
- the result of the successful executionprotected abstract void updateStatistics()
protected abstract Member getMember(ReliableTopicMessage m)
public void onFailure(Throwable t)
ExecutionCallback
onFailure
in interface ExecutionCallback<ReadResultSet<ReliableTopicMessage>>
t
- the exception that is thrownprotected boolean handleInternalException(Throwable t)
t
- throwable to check if it is terminal or can be handled so that topic can continueprotected abstract Throwable adjustThrowable(Throwable t)
t
- throwableprotected abstract long getHeadSequence(StaleSequenceException staleSequenceException)
public void cancel()
public boolean isCancelled()
Copyright © 2019 Hazelcast, Inc.. All Rights Reserved.