Publisher
The Publisher class sends single row updates to a specified table in Data Refinery. The Publisher accepts a string array containing the column names and a generic object array that contains the row values. The column names and row values must be in the same order as the table in Data Refinery. Publishers are registered by the Service class. (i.e. the Java Service class registers the publisher with the Refinery messaging server).
Note
For Kx Refinery environments running Hot-Hot, this must be repeated on the secondary side, if there is one. It is the user's responsibility to publish identical data to both sides (primary & secondary), and to handle any and all failover scenarios (including how to publish any backlog of data)._
The Publisher class exposes the following public methods:
- Publish : Publish data to the subscribers.
- SubscriptionAdded : Adds a subscriber to this publisher.
- SubscriptionRemoved : Removes a subscriber to this publisher.
- HasSubscribers : Indicates whether this publisher has any subscribers.
- WaitForSubscribers : Waits for subscribers to be added to the publisher.
Here is an example of using the Publisher class:
public void Publish_to_fiTrade_table() throws Exception, ServiceException {
Service service = createService();
service.start(Duration.ofSeconds(20));
service.startMessagingServer(messagingServerConfigName);
Publisher pub = new Publisher("fiTrade");
service.registerPublisher(pub, "emea_tr_fi", "fiTrade", null);
pub.waitForSubscribers(Duration.ofSeconds(20));
String[] colNames = new String[] {
"time",
"sym",
"exchTime",
"price",
"volume",
"conditions",
"normalisedCondition",
"tickDirection",
"tradedExchange",
"sequenceNumber",
"accVol",
"tickCount",
"tradeId"
};
Object[] data = new Object[]{
Timestamp.from(Instant.now()),
"VOD",
Timestamp.from(Instant.now()),
1000.0,
1L,
"U||XLON|U||||POP|SET1|||".toCharArray(),
"AU",
1,
"XLON",
1L,
1L,
1L,
"1822058950427310".toCharArray()
};
Thread.sleep(5000);
pub.publish(colNames, data);
service.unregisterPublisher(pub, "fiTrade", null);
};
The /src/test/java/com/fd/daas/api folder (test folder) contains additional examples.