public class KdbConsumer extends KdbConnection
Provides the ability to consume real-time streaming data from a KDB process
into a KdbTable
for use within a Java application
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
log |
private IKdbRawDataConsumer |
rawDataConsumer
A listener object that will consume any valid message received from the kdb process
|
private static String |
SUB_FUNCTION |
private KdbDict |
subscriptionConfiguration
An optional dictionary of subscription information if the upstream kdb process supports subscription configuration
|
private List<String> |
subscriptionTables
The list of tables that this consumer will subscribe to
|
private static List<String> |
SUPPORTED_UPD_FUNCTIONS |
private IKdbTableConsumer |
tableConsumer
A listener object that will only consume table updates
|
private static Integer |
UPD_ARRAY_LENGTH
The length of the array returned by kdb in order for it to be considered as a valid update message
|
reconnectIntervalMs
Modifier | Constructor and Description |
---|---|
protected |
KdbConsumer(KdbProcess server,
KdbDict subscriptionConfiguration,
IKdbRawDataConsumer rawDataConsumer,
IKdbTableConsumer tableConsumer) |
protected |
KdbConsumer(KdbProcess server,
List<String> tables,
IKdbRawDataConsumer rawDataConsumer,
IKdbTableConsumer tableConsumer)
Generates a new kdb consumer (which is generally a consumer from a kdb TickerPlant)
|
|
KdbConsumer(KdbProcess server,
List<String> tables,
IKdbTableConsumer tableConsumer) |
private |
KdbConsumer(KdbProcess server,
List<String> tables,
KdbDict subscriptionConfiguration,
IKdbRawDataConsumer rawDataConsumer,
IKdbTableConsumer tableConsumer) |
Modifier and Type | Method and Description |
---|---|
private void |
listen()
Commences listening for messages to be sent to this consumer from the kdb process.
|
void |
reconnect()
Performs the reconnection logic as defined in the super class.
|
private Boolean |
subscribe()
Performs a subscription request to the kdb process (
.u.sub ) with the specified list of tables
and symbols specified at object construction time |
void |
subscribeAndListen()
Once connection to the process has been established (performed during object construction), then this function
is called to first subscribe to the kdb TickerPlant and, if successful, start listening for update messages
|
close, connect, disconnect, getConnection, getRemoteProcess, isConnected
private static final org.slf4j.Logger log
private static final String SUB_FUNCTION
private static final Integer UPD_ARRAY_LENGTH
private final List<String> subscriptionTables
private final KdbDict subscriptionConfiguration
private final IKdbRawDataConsumer rawDataConsumer
private final IKdbTableConsumer tableConsumer
private KdbConsumer(KdbProcess server, List<String> tables, KdbDict subscriptionConfiguration, IKdbRawDataConsumer rawDataConsumer, IKdbTableConsumer tableConsumer) throws KdbTargetProcessUnavailableException
protected KdbConsumer(KdbProcess server, List<String> tables, IKdbRawDataConsumer rawDataConsumer, IKdbTableConsumer tableConsumer) throws KdbTargetProcessUnavailableException
server
- The kdb process to connect totables
- The list of tables that should be subscribed to. NOTE: This cannot be null, pass an empty listrawDataConsumer
- A listener object that will consume every message from the kdb processtableConsumer
- A listener object that will consume only table messages from the kdb processKdbTargetProcessUnavailableException
- If the consumer cannot connect to the target kdb processNullPointerException
- If either tables
or syms
is null. Also if both rawDataConsumer
and tableConsumer
null, the constructor must be passed one or the otherprotected KdbConsumer(KdbProcess server, KdbDict subscriptionConfiguration, IKdbRawDataConsumer rawDataConsumer, IKdbTableConsumer tableConsumer) throws KdbTargetProcessUnavailableException
public KdbConsumer(KdbProcess server, List<String> tables, IKdbTableConsumer tableConsumer) throws KdbTargetProcessUnavailableException
public void subscribeAndListen() throws KdbProcessSubscriptionFailedException
KdbProcessSubscriptionFailedException
- If the subscription to the TickerPlant failssubscribe()
,
listen()
public void reconnect()
reconnect
in class KdbConnection
KdbConnection.reconnectIntervalMs
private Boolean subscribe() throws UnsupportedOperationException
.u.sub
) with the specified list of tables
and symbols specified at object construction timeTrue
if the subscription result from the kdb process is not null, false
otherwiseUnsupportedOperationException
private void listen()
rawDataConsumer
,
tableConsumer
Copyright © 2017. All rights reserved.