Reading over Web Sockets
You can read data over Web Sockets using the Extensible Common Data Adapter (ECDA) or ECD Agent. This feature is new in s-Server 5.2.
All adapter or agent implementations involve configuring options. For adapters, you configure and launch the adapter in SQL, using either server or foreign stream/table options. For agents, you configure such options using a properties file and launch the agent at the command line. Many of the options for the ECD adapter and agent are common to all I/O systems. The CREATE FOREIGN STREAM topic in the Streaming SQL Reference Guide has a complete list of options for the ECD adapter.
To read from the file system, you need to create a server object which references the data wrapper ECDA and is of type 'HTTP'.
CREATE OR REPLACE SERVER "WebSocketReaderServer" TYPE 'websocket'
FOREIGN DATA WRAPPER ECDA;
Note: ECD Adapter server definitions need to reference the ECD foreign data wrapper. You can do so with the syntax FOREIGN DATA WRAPPER ECDA.
Unlike server objects, all foreign streams need to be created in a schema. The following code first creates a schema in which to run the rest of the sample code below, then creates a foreign stream named "FileReaderStream."
CREATE OR REPLACE SCHEMA "FileSource";
SET SCHEMA '"FileSource"';
CREATE FOREIGN STREAM "Web_Socket_Stream"
--Columns for the new stream
--This needs to be a web socket accessible from s-Server
"HEADER_Authorization" 'token d90621ca-9601-4a49-96f3-160f61082c34',
The ECD agent takes similar options, but these options need to be formatted in a properties file along the lines of the following. These properties correspond to those defined for the adapter above.
ROWTYPE=RECORDTYPE(VARCHAR(2040) id, VARCHAR(2040) reported_at, VARCHAR(2040) shift_no, VARCHAR(2040) trip_no, VARCHAR(2040) route_variant_id)
The code sample above uses CSV as a format. To use other file options, see the File Formats for Reading topic in this guide.