-
Notifications
You must be signed in to change notification settings - Fork 4
KdbPublisher
These classes provide the ability to publish updates to a kdb+ process (via .u.upd) asynchronously.
The publisher also supports auto-reconnection to the kdb+ process after a configurable amount of time has passed since the last publish to the process. This is to improve publish reliability when the connection is dropped remotely and Java does not detect it.
KdbPublisherThread simply wraps KdbPublisher into its own thread to take the processing of the update messages from the constructing thread. The thread is started automatically as part of the object construction.
To configure the publisher you need to specify the target kdb+ process to publish to (using a KdbProcess object).
By default, the standard inactive reconnection interval is 30 minutes. This means if there has been no data published for 30 minutes, then the publisher automatically reconnects to the target process prior to sending the data. To modify this, use the Joda time Duration class (e.g. Duration.standardMinutes(30)).
You can send data to be published either in KdbTable form (which is recommended) or in Flip form:
publish(KdbTable)publish(List<KdbTable>)-
publish(String, Flip)requires the table name as well as the table data to be passed
Each publish function returns a boolean (or list of booleans) to inform you if the publish was successful or not. Note that because the publish is done asynchronously this is only detecting send errors from the Java side, not that the kdb process processed the data correctly.
public KdbPublisherThread startPublisher() throws KdbTargetProcessUnavailableException {
KdbProcess target = new KdbProcess("localhost", 54321);
return new KdbPublisherThread(target);
}
// Example publish, connect / publish / disconnect in single function
public void publishSomething() {
KdbPublisherThread publisher = startPublisher();
KdbTable emptyTable = new KdbTable("trade");
publisher.publish(emptyTable);
publisher.disconnect();
}Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2021