public class SimpleMessageHandler extends Object implements MessageHandler
This example makes some effort to avoid excessive allocation by reusing buffers for incoming data but makes a compromise for convenience and still allocates for some immutable objects like Strings, BigDecimal, etc.
NOTE: this implementation is not thread safe. A unique instance must be passed to each concurrent TableClient
.
Constructor and Description |
---|
SimpleMessageHandler()
Construct a new simple message handler.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(SimpleMessageHandlerListener listener)
Add a listener to handle incoming decoded messages from the table server.
|
void |
decodeBeginTableUpdate(BeginTableUpdateDecoder beginTableUpdateDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a BeginTableUpdate message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(BooleanArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a BooleanArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(BooleanColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a BooleanColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(ByteArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a ByteArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(ByteColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a ByteColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(CharArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a CharArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(CharColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a CharColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(DateTimeColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a DateTimeColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(DecimalColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a DecimalColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(DoubleArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a DoubleArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(DoubleColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a DoubleColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(FloatArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a FloatArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(FloatColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a FloatColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(IntArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode an IntArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(IntColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode an IntColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(LongArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a LongArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(LongColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a LongColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(ShortArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a ShortArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(ShortColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a ShortColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(StringArrayColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a StringArrayColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(StringColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a StringColumnData message and pass along to any interested listeners.
|
void |
decodeColumnUpdate(StringSetColumnDataDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a StringSetColumnData message and pass along to any interested listeners.
|
int |
decodeConnectionResponse(ConnectionResponseDecoder connectionResponseDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode the connection response and allocate buffers according to the message buffer size indicated by the
server.
|
void |
decodeEndTableUpdate(EndTableUpdateDecoder endTableUpdateDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode an EndTableUpdate message and pass along to any interested listeners.
|
void |
decodeRowsRemoved(RowsRemovedDecoder decoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a RowsRemoved message and pass along to any interested listeners.
|
void |
decodeSubscribeResponse(TableSubscribeResponseDecoder subscribeResponseDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a SubscribeResponse message and pass along to interested listeners.
|
void |
decodeSubscriptionError(TableSubscriptionErrorDecoder subscriptionErrorDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode a SubscriptionError message and pass along to any interested listeners.
|
void |
decodeUnsubscribeResponse(TableUnsubscribeResponseDecoder unsubscribeResponseDecoder,
org.agrona.concurrent.UnsafeBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
Decode an UnsubscribeResponse message and pass along to interested listeners.
|
void |
handleConnectionError(IOException ex)
Handle a connection error by passing it on to any interested listeners.
|
public SimpleMessageHandler()
public void addListener(SimpleMessageHandlerListener listener)
listener
- The listenerpublic void handleConnectionError(IOException ex)
handleConnectionError
in interface MessageHandler
ex
- The exception that resulted in this notificationpublic int decodeConnectionResponse(ConnectionResponseDecoder connectionResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeConnectionResponse
in interface MessageHandler
connectionResponseDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeSubscribeResponse(TableSubscribeResponseDecoder subscribeResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeSubscribeResponse
in interface MessageHandler
subscribeResponseDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeUnsubscribeResponse(TableUnsubscribeResponseDecoder unsubscribeResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeUnsubscribeResponse
in interface MessageHandler
unsubscribeResponseDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeSubscriptionError(TableSubscriptionErrorDecoder subscriptionErrorDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeSubscriptionError
in interface MessageHandler
subscriptionErrorDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeBeginTableUpdate(BeginTableUpdateDecoder beginTableUpdateDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeBeginTableUpdate
in interface MessageHandler
beginTableUpdateDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeEndTableUpdate(EndTableUpdateDecoder endTableUpdateDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeEndTableUpdate
in interface MessageHandler
endTableUpdateDecoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeRowsRemoved(RowsRemovedDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeRowsRemoved
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(ByteColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(BooleanColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(CharColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(DoubleColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(FloatColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(LongColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(DateTimeColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(IntColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(ShortColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(ByteArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(BooleanArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(CharArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(DoubleArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(FloatArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(IntArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(LongArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(ShortArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(DecimalColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(StringColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(StringArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)public void decodeColumnUpdate(StringSetColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
decodeColumnUpdate
in interface MessageHandler
decoder
- Decoder which can be used to extract the message from the given bufferdirectBuffer
- The underlying receive bufferbufferOffset
- The offset in the given buffer at which to start decodingactingBlockLength
- Block length from SBE header (pass to decoder wrap method)actingVersion
- Version from SBE header (pass to decoder wrap method)