Subscribing to a Data Stream

To receive data from a Sybase CEP data stream, the subscriber must perform an HTTP GET request to the Sybase CEP Server.

The HTTP GET request must include the following HTTP headers and an empty HTTP body:

GET <path> HTTP/1.0\r\n
Host: <server-hostname-or-ip>\r\n
X-C8-StreamFormat: <stream-format>\r\n
X-C8-StreamFormatOptions: <stream-format-options>\r\n
\r\n

where

The "\r\n" represents the 2-character sequence carriage return and line feed, not the 4-character literal "\r\n".

Note:
Note: The header is followed by a blank line terminated with a carriage return and line feed.

The client should expect to receive an HTTP response tha contains an HTTP header and an HTTP body. Since the data stream may continue indefinitely, the HTTP body is essentially an endless series of messages, each of which will have data in the stream format specified in the HTTP request. A typical HTTP response looks similar to the following:

HTTP/1.0 200 OK\r\n<header1>: <header-value1>\r\n<header2>: <header-value2>\r\n
...
<headerN>: <header-valueN>\r\n
\r\n
<data-in-specified-data-stream-format>

where

As before, the "\r\n" represents the two character sequence of a carriage return followed by a line feed.

The Sybase CEP HTTP response is different from most HTTP responses from entities other than Sybase CEP Server. The output data stream is a series of messages that may continue indefinitely, so there is no way for the response to specify the length of the message in the header. Furthermore, the response is a series of messages and each of those messages should be dealt with when the message arrives. The recipient does not wait until the end of the HTTP response to start processing the messages in it.

For example, the following HTTP request subscribes to stream /Stream/Default/Finance/StreamIn :

GET /Stream/Default/Finance/StreamIn HTTP/1.0\r\n
Host: localhost\r\n
X-C8-StreamFormat: CSV\r\n
X-C8-StreamFormatOptions: TitleRow=true,
TimestampColumn=true,
TimestampColumnFormat=YYYY/MM/DD HH24:MI:SS\r\n
\r\n
Note: Due to limitations on the page width of this manual, the X-C8-StreamFormatOptions line is shown as split across multiple lines, but is really a single line. Note carefully where the "\r\n" sequences are shown.

The subscriber receives trading data in CSV format in the following HTTP response:

HTTP/1.0 200 OK\r\n
Date: Wed, 28 Jan 2005 10:23:53 GMT\r\n
\r\n
Timestamp,Symbol,Price,Volume\r\n
"2005/01/28 10:23:54",ABC,11.40,300000\r\n
"2005/01/28 10:23:55",XYZ,32.84,1260000\r\n
...