Compliance Sample

Compliance is an example of a production-level StreamBase application that manages a stock portfolio and checks for compliance of buy transactions against a set of rules governing the exchange.

Installed Sample File Locations

By default, the sample files are installed in:

  • On Windows: C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\compliance

  • On UNIX: /opt/streambase/sample/compliance

The Compliance Sample Application consists of:

  • The application, compliance.sbapp

  • A sample Java and C++ enqueuer to preload shared data in the application, using the StreamBase C++/Java Client API

  • A sample Java and C++ dequeuer to view the application's output, using the StreamBase C++/Java Client API

  • An sbfeedsim configuration file, compliance.sbfs.

  • Java and C++ source code for the above programs.

  • Either Microsoft Visual Studio .Net solution and project files (Windows) or a Makefile (UNIX) that can be used to (re)build all of the sample source code. (In the Visual Studio files, the paths to find StreamBase include files and libraries are configured to run from the installation directory.)

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 application from the Applications list.

  • Click OK.

StreamBase Studio creates a project for each sample.

Running the Compliance Sample

Important

The compliance.sbapp application cannot be run in StreamBase Studio, because it contains group-by elements that are based on legacy (pre-3.7) feed simulations, which are not supported in the new (3.7+) feed simulations. For this reason, the procedures in this section use the sbfeedsim-old command to run the Compliance sample in terminal windows.

On UNIX

  1. Open three terminal windows. In each window, change directory to the installed compliance sample file location. For example:

    cd /opt/streambase/sample/compliance.

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

    sbd compliance.sbapp

  3. In the second terminal window, enter either of the following commands to run the preloader, and wait until it is done:

    • C++ version: ./preload

    • Java version: java -classpath `sb-config --classpath`:preload.jar com.streambase.sample.compliance.Preload

  4. Still in the second terminal window, run the output viewer by entering either of these commands:

    • C++ version: ./outputviewer

    • Java version: java -classpath `sb-config --classpath`:outputviewer.jar com.streambase.sample.compliance.OutputViewer

  5. In the third terminal window, run the sbfeedsim-old command on the legacy configuration file, suppressing the printout of tuples:

    sbfeedsim-old -q compliance.sbfs

    Note

    This legacy (pre-3.7) feed simulation contains group-by elements that are not supported by the current Feed Simulator and its sbfeedsim command.

On Windows

  1. Open three StreamBase Command Prompt windows. In each window, change directory to the installed compliance sample file location. For example:

    cd C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\compliance

  2. In the first command window, launch a StreamBase Server on compliance.sbapp:

    sbd compliance.sbapp

  3. In the second window, enter either of the following commands to run the preloader, and wait until it is done:

    • C++ version: preload

    • Java version: java -classpath "streambase-install-dir\lib\sbclient.jar";preload.jar com.streambase.sample.compliance.Preload

  4. Still in the second command window, run the output viewer:

    • C++ version: C++: outputviewer

    • Java version: java -classpath "streambase-install-dir \lib\sbclient.jar;outputviewer.jar" com.streambase.sample.compliance.OutputViewer

      For example:

      java -classpath "C:\Program Files\StreamBase Systems\StreamBase.n.m\lib\sbclient.jar;outputviewer.jar" com.streambase.sample.compliance.OutputViewer

  5. In the third command window, run the sbfeedsim-old command on the provided configuration file, suppressing the printout of tuples:

    sbfeedsim-old -q compliance.sbfs

If the StreamBase Server is running on a different system, use the option -u to specify the StreamBase Server URI (by default, sb://localhost).