Writing over HTTP
To write data to an HTTP server, use the Extensible Common Data Framework. This feature is new as of version 5.2.
Version 5.2 Feature
For adapters, you configure and launch the adapter in SQL, using either server or foreign stream/table options.See the topic CREATE SERVER in the s-Server Streaming SQL Reference Guide for more details. 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.
Note: Because of the nature of streaming data, you will need to set up a pump in order to move rows continually from an s-Server stream to another stream, file, Kafka topic, RDBMS table or other location. Pumps are INSERT macros that continually pass data from one point in a streaming pipeline to the other. A model for setting up a pump is provided below. See the topic CREATE PUMP in the s-Server Streaming SQL Reference Guide for more details.
Configuring the ECD Adapter for HTTP
You configure the Extensible Common Data Adapter (ECDA) to read or write over HTTP using server options and foreign table/stream options. You configure the Extensible Common Data Agent using the same options in a property file. See the topic Extensible Common Data Agent Overview for more details.
To write over HTTP, you need to create a server object which references the data wrapper ECDA and is of type 'HTTP', as in the following code. See the topic CREATE SERVER in the Streaming SQL Reference Guide for more details.
CREATE OR REPLACE SERVER "HTTPwriterServer" TYPE 'HTTP'
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.
Next, you create a foreign stream object. This object contains connection information for the HTTP server, such as its URL.
Streams, like most SQL objects (but unlike data wrappers and servers), should be created within 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
CREATE OR REPLACE SCHEMA "HTTPSource";
SET SCHEMA '"HTTPSource"';
CREATE OR REPLACE FOREIGN STREAM "HTTP_writerStream"
Using the ECD Agent to Write ad Over HTTP
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 Output Formats for Writing topic in this guide.