Using the Sample Program for the kdb Insights C# Interface
This page describes how to use our sample C# program, available on the KX Downloads Portal, to:
- Publish data from the
sample.csvfile to either:- kdb Insights Reliable Transport
- A
kxi-dbpackage inside the kdb Insights Enterprise. You can download this package using these instructions.
- Subscribe to data from kdb Insights
Downloading
The RTHelper.<version>.<os>.nupkg, which you can download from the KX Downloads Portal, contains the following files:
CsvUpload.csOneRecordUpload.csBatchUpload.csSubscriberExample.cssample.csv
Before using the sample program you must install the C# interface.
Unzipping
Unzip the .nupkg to access the sample programs.
unzip RTHelper.$version.$os.nupkg
Publishing
To execute the sample program to publish data to an RT stream, use the following commands:
cd samples/csvupload
dotnet build
dotnet run -- -u <configUrl> -s "sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:byte,alarm:byte" -t trace -i sample.csv
The -u argument can be either:
- a kdb Insights Enterprise client URL or
- a URL to a local JSON file (
file://...) containing the RT configuration.
See the Getting Started Guide for further information on obtaining such a URL.
The program will upload the sample.csv file and then exit.
Application parameters
csvupload demonstrates how to publish data from the sample.csv file and the following parameters are used to configure the application:
| parameter | required | default | description |
|---|---|---|---|
-s str |
Mandatory | none | Schema - see note below. |
-t str |
Mandatory | none | Table (for example: "trace") |
-i str |
Mandatory | none | Input CSV file |
-u str |
Optional | none | Authenticated client URL |
-y str |
Optional | none | clientName, note: "-y clientName" together with "-q streamName" can be used instead of "-u configUrl" |
-v str |
Optional | none | streamPrefix, note: "-y clientName" together with "-v streamPrefix" and "-q stream" can be used instead of "-u configUrl" |
-q str |
Optional | none | stream, note: "-v streamPrefix" and "-q stream" together with "-y clientName" can be used instead of "-u configUrl" |
-p str |
Optional | none | Endpoints, eg. "hostname1:port,hostname2:port,hostname3:port" note: this will only be used if config URL is not provided |
-o int |
Optional | none | loop, send file many times, -1 for infinite loop, defaults to 1 |
The schema defined here MUST match what is defined in the package
s str: The schema must match that defined in the pipeline. If the schema in the table matches the one in thekxi-db, described here, the schema definition is as follows: sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:int,alarm:int
Subscribing
To execute the sample program to subscribe to data, use the following commands:
cd samples/SubscriberExample
dotnet build
dotnet run -- -f <filter> -p <RT sub_server endpoint>
dotnet run -- -f <filter> -u <configUrl>
dotnet run -- -f <filter> -q <stream>
The program will subscribe to data from an RT stream and display the messages on the console.
Application parameters
SubscriberExample demonstrates how to subscribe to data from RT and the following parameters are used to configure the application:
| parameter | required | default | description |
|---|---|---|---|
-p str |
Optional | none | End-points, eg. "hostname1:port,hostname2:port,hostname3:port" - see note below. |
-u str |
Optional | none | Authenticated client URL - see note below. |
-q str |
Optional | none | Stream - see note below. |
-f str |
Optional | "" | Table name filter to apply to the subscription. |
-s int |
Optional | 5003 | Port of the subscriber endpoint(s) on the RT node. |
-l int |
Optional | 5001 | Port of the publisher endpoint(s) on the RT node. |
-L str |
Optional | INFO | Logging level - Can be NONE, FATAL, ERROR, WARN, INFO, DEBUG or TRACE |
-d int |
Optional | 30 | Duration for which the subscriber application runs, -1 for infinite |
Provide one of the following
- Either
-p <host:port>[,<host:port>...]or-q <stream>or-u <configUrl>can identify the RT server.