Create a real-time engine

First, create the RTE process in Kx Control.

  1. Right-click on the Process Library and select New > Process Instance from the context menu.

  2. Name the process dhtRTE, set the template to DS_RTE, and click Add.

    Screenshot

  3. In the Instance Details subtab, set the description.

  4. In the Shutdown Alerts subtab, set the shutdown alerts.

  5. In the Reserved Parameters, set the host and port. Use one of the computed ports like the other instances have been using such as ENV=DELTACONTROL_PORT=+2004

  6. In the Instance Parameters subtab, set the messagingServer to the same one previously used (DS_MESSAGING_SERVER:dhtDMServer), set the publishChannel to datafeed and set the publishTableList to dhtQuotes, dhtTrades. The last is extremely important. When the RTE adds data to the published tables, the message server notifies all other processes subscribed to the datafeed that a change has been made and they can update accordingly.

  7. In the Schemas subtab, associate the dhtSchemaGroup.

  8. In the Analytics subtab, associate the dhtDummyData group.

  9. Save the process instance.

Next, experiment with the RTE. Start dhtWorkflow and filter for instances using the prefix dht. The Process Library Status viewer will look similar to the screenshot below: all dht processes except for dhtRTE.

Screenshot

Right-click on dhtRTE and run the process instance. The Process Library Status viewer will now look like:

Screenshot

Connect to an Kx Analyst IDE on the dhtRTE instance using the context menu on the instance. Open the (Global) module and table folder. Open a scratchpad and type tables[]; into the scratchpad and display the result of the function. This is a typical setup when working with an instance. On the left, all the code modules in your process are displayed. On the right is the scratchpad where commands can be run, data items inspected, and console outputs viewed.

Screenshot

Look in the tree on the left, find the loadDummyData analytic. If it’s missing, go back and make sure it was added to the Analytics subtab of the RTE, and restart the RTE instance.

Screenshot

Next run the function created earlier; enter the full namespace path name of the function and Execute it.

Screenshot

If everything worked correctly, the .d.pub function inside the loadDummyData function should publish the dummy data to the dhtQuotes and dhtTrades tables. To see if it worked, look at the RDB as it's subscribed to receive table updates via datafeed. Open an Kx Analyst IDE to the RDB task or instance by right-clicking on the RDB in the Process Library Status viewer in Kx Control and clicking Connect. Once connected you can use the display menu item on dhtTrades or dhtQuotes in the Scratchpad.

Screenshot

An alternative way of looking at the tables is to inspect them as shown below. The Visual Inspector allows users to inspect data values in a table view as well as explore their data graphically.

Screenshot

Screenshot

If no data is visible

Check the following:

  1. Are the schemas associated with the RTE and RDB processes?
  2. Is the analytic group associated with the RTE process?
  3. Is there a subscription to datafeed in the RDB?
  4. Is the publish channel datafeed in the RTE?
  5. Is there an association in the messaging server via the config parameter with the RTE and RDB?
  6. Check for typos in any of the entities, columns, others.

Hopefully, the RTE is now publishing dummy data to the tables. However, it’s impractical to have to add records manually each time the process is started. Instead, add a timer function so records are added automatically every few seconds.

In Kx Control use the context menu on the Analytic group dhtDummyData and choose New Analytic. Name the analytic initRTE. By using the create menu within the package and within the Analytic group, these are automatically associated with the new entity. This can save a few steps when building up a package.

Screenshot

Screenshot

In the analytic editor, ensure the Groups tab already has the dhtDummyData analytic group and if not, add it. In the Contents tab enter the following code. When this code executes, it will start a timer that will execute the loadDummyData with a parameter of 10 every 5000ms.

The .d.prcl.addFuncToTimer function takes the following parameters as shown by the content assist in the analytic editor (ctrl-space / cmd-space)

Screenshot

Copy and paste in the following line.

.d.prcl.addFunctToTimer[`loadDummyData; 10; 0Nz; 0Nz; 5000; 1b];

Save.

Screenshot

Restart the workflow and restart the RTE. Open the RTE and the RDB in the Kx Analyst IDE. In the RTE instance, run the function initRTE[] from the scratchpad.

Screenshot

In the RDB instance, check that the tables are increasing in size.

Screenshot

Go back to Kx Control and stop the workflow and the RTE.

In the Instance Parameters subtab of the RTE instance, set the initStateFunc to initRTE. This function will execute when the RTE initializes.

Screenshot

Open up the dhtWorkflow.

Click on the New Task button, enter the following information into the dialog, and click Add.

Screenshot

The task appears in the workflow.

Screenshot

Click the Add Connection button. In the dialog, connect from dhtRDB.1 to dhtRTE.1 and press Add.

Screenshot

Save and start the workflow.

Open the Kx Analyst IDE on the dhtRDB.1 task. This will open the dhtRDB instance in Kx Analyst. Check that data is being incrementally added to the dhtTrades table.

Screenshot

This should produce a fully-functioning data-capture system with synthetic data, manufactured by a real-time engine, populating data tables.