CSV File Reader Input Adapter Sample

This sample demonstrates a StreamBase application that processes financial tick data from three financial feeds. The application determines the fastest of the three feeds, computes useful statistics for each feed, and calculates the VWAP for the incoming tick data.

This sample is based on another sample included in the StreamBase distribution, installed in streambase-install-dir/sample/feedproc. In the FeedProc example, there are three input streams fed by a feed simulation. By contrast, this sample uses three CSV Reader embedded adapters in place of the three input streams. Please refer to FeedProc Sample for more information about the application itself.

The CSV Reader adapter and the sbfeedsim command share some characteristics. They both essentially read records from a CSV file and turn them into tuples. The CSV Reader runs in the same process space as the StreamBase application, while sbfeedsim runs as a separate process. Each of these approaches might be preferred under different circumstances.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top menu, click FileLoad StreamBase Sample.

  • Select this sample from the Embedded Adapters list.

  • Click OK.

StreamBase Studio creates a single project containing the sample files.

Installed Sample File Locations

By default, the sample files are installed in:

On Windows

C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\adapter\embedded\csvreader\

On UNIX

/opt/streambase/sample/adapter/embedded/csvreader/

Running This Sample in StreamBase Studio

In the Package Explorer, double-click to open the feedproc.sbapp application. Make sure the application is the currently active tab in the EventFlow Editor.

Click the Run StreamBase Application (Default Launch) button. (Not the Run button.)

StreamBase Studio changes to the Test/Debug perspective. The output is displayed in the Application Output view.

Running This Sample in Terminal Windows

  1. Open two terminal windows (UNIX) or two StreamBase Command Prompt windows (Windows). In each window, navigate to the installed sample location as shown above.

  2. In the first terminal window, launch a StreamBase Server on feedproc.sbapp:

    sbd feedproc.sbapp

    If the StreamBase Server is running on a different system, use the -u option to specify the server's URI.

  3. In the second terminal window, run the output viewer from the FeedProc sample by entering the following command. If you installed StreamBase in a non-default location, correct the paths in these sample lines:

    On UNIX
    java -classpath `sb-config --classpath`:\
    /opt/streambase/lib/sbclient.jar:\
    /opt/streambase/sample/feedproc/FeedProc.jar FeedProc
    
    On Windows
    set SB_HOME="C:\Program Files\StreamBase Systems\StreamBase.n.m"
    java -classpath "%SB_HOME%\lib\sbclient.jar;%SB_HOME%\sample\feedproc\FeedProc.jar" FeedProc
    

    Note

    If you take a long time to start step 3, the FeedProc viewer might show empty results. In this case, restart the commands in both windows, starting step 3 within a few seconds of step 2.

  4. To stop the sample:

    • Close the FeedProc viewer application window.

    • Issue the following command to shut down the sbd server: sbadmin shutdown

Related Topics