Attaching an Input Adapter

Attach an input adapter to your input stream. This adapter converts data from an external source.

After creating an input stream and specifying the format for the data on that stream, create a mechanism for feeding or publishing data to the stream. Input adapters convert data from an external source into a Sybase CEP-compatible format. Input adapters are attached to input streams.

Follow these steps to attach an input adapter to your data stream:

  1. Click StockTrades in the Explorer view.
  2. On the Project menu, click Attach Input Adapter:

    AttachAdapterDialog PNG
  3. In the Type list, click Read from CSV File and then click OK:


    SFInRFCSV PNG

    The Queries tab now includes the CCL statement that attaches the input adapter and the Properties view now displays properties specific to this adapter. To see an explanation of a particular property, click its name. Clicking the name again closes the explanation. The Flow view also displays the input adapter and shows the connection to the input stream.

  4. Examine the new statement in the Queries tab:


    AttInAdapter CCL PNG

    An Attach Adapter statement specifies the kind of adapter (INPUT), the name of the adapter (ReadFromCSVFile), the type of adapter (ReadFromCSVFileAdapterType), and the name of the stream to which it is attached (StockTrades). Finally, a list of PROPERTIES modify the behavior of the adapter. Each type of adapter uses different properties. This adapter requires the name of a file. For more information about the Attach Adapter statement, see "ATTACH ADAPTER Statement" in the Sybase CEP CCL Reference Guide . For more information about adapters and adapter properties, see "Adapters Supplied by Sybase CEP" in the Sybase CEP Integration Guide .

  5. In the Queries tab, replace "ReadFromCSVFile" with "StockTradesReader" to change the name of the adapter.
  6. In the Properties view, click the Select an existing file button (labeled with an open folder), to the right of the Filename text box:


    CSVFileWarning PNG

    The warning that appears explains that Sybase CEP Studio expects that the files you use with input adapters are kept in the SybaseC8Repository. Sybase CEP Server expects input files to be in the adapters base folder. If you install both applications on the same computer, then both Sybase CEP Studio and Sybase CEP Server use the same folder. If you install the applications on separate computers, or if someone modifies the default settings for either Sybase CEP Studio or Sybase CEP Server, then you will not be able to use this method to identify input adapter data files.

  7. Click OK.
  8. Locate the SybaseC8Repository (in Windows, the default location is under My Documents), and navigate to version/examples/GettingStarted/DataFiles (where version is the version number of Sybase CEP Engine) and then open the file stock-trades.csv .
  9. In the Properties view, type "2" into the Rate text box to indicate that the adapter should read two rows per second from the file. This slow rate allows you to see the behavior of the project more easily when you run it. Without this rate, the entire data file is processed in less than a second.
  10. Clear the File Has Timestamp Column check box and then check the Set Timestamp To Current Time check box to indicate that the data file does not include a timestamp and that Sybase CEP Engine should assign the current time to each row as it arrives. The Properties tab should look like this:


    SFIAwithFile PNG

    And the Queries tab should look like this:


    SFIACCL PNG

    Again, you can choose to set adapter properties either with the Sybase CEP Studio UI elements or by typing the CCL text into the Queries tab directly. The order of the lines specifying the properties is not significant.