StreamBase Documentation
Samples Guide
The StreamBase kit provides sample EventFlow applications to demonstrate key product features and to help you learn how to use them. Each sample has its own emphasis; for example, a sample may highlight a particular type of data processing operator, while another may describe the configuration details for a distributed environment. This topic describes the StreamBase samples, including their location and purpose, how we built them, and how to run them.
- Pointers to the StreamBase Samples
- API Samples
- Extending StreamBase: Custom Clients, Functions, Embedded Adapters, and Java Operators
- Sample EventFlows, which includes pointers to many .sbapp sample applications
- StreamBase Tutorials
- Installed Locations
- Importing Samples into StreamBase Studio Projects
- Rebuilding Samples on Windows
Loading Samples into StreamBase Studio Projects
To load a sample into StreamBase Studio:
- From the top menu, click File > Load Samples...
- Select one or more samples from the
Load Sample Projectsdialog.
For example:

StreamBase Studio will create a separate project for each sample. In the case of the "operator" samples, one project will be created and all the individual operator's *.sbapp sample applications will be imported into the single Application Diagrams folder.
If you load a sample (such as compliance or custom-aggregate-function) into StreamBase Studio, and that sample contains a custom function or client, StreamBase Studio will automatically send the executable file and its configuration settings to StreamBase Server. For related information, see these topics in the API Guide:
Pointers to the StreamBase Samples
The StreamBase kit provides several types of samples to demonstrate the key product features. Each sample has its own emphasis; for example, a sample may highlight a particular type of data processing operator, while another may describe the configuration details for a distributed environment. This section describes each of the groups in the Load Sample Projects dialog.
API Samples
These samples demonstrate how to work with the StreamBase-provided APIs to create client programs:
- Buffering Sample Highlights the tuple buffering options for "producer" or "enqueue" clients.
- Java or C++ Client Sample Provides sample enqueue and dequeue clients; that is, enqueuing (adding) tuples onto a named stream, and dequeuing (reading) processed tuples from a named stream. The samples include both Java or C++ sources.
Extending StreamBase: Custom Clients, Functions, Embedded Adapters, and Java Operators
You can extend StreamBase by writing your own custom clients, functions, embedded adapters, and Java operators. The following samples are provided:
- UTF-16 Sample Demonstrates StreamBase's support for UTF-16 character data, and includes documentation about the
utf16custom Java functions. - Custom C++ Function Samples Contains examples of an aggregating function (
custom-aggregate-function) function and a "simple" (non-aggregating) function (custom-simple-function). - Custom Java Simple Function Sample Contains a "simple" (non-aggregating) calljava function.
- Custom Java Aggregate Function Sample Contains an aggregating calljava function.
- Java Operator Sample Contains a StreamBase application and a StringCase class that extends com.streambase.sb.streambase.operator.
- StreamBase also provides embedded adapters to convert data from external resources (input adapters) into StreamBase tuples, and from StreamBase tuples to external formats (output adapters). Embedded adapters run in the same server process that is hosting and processing your StreamBase application's requests. See StreamBase Adapters Guide for descriptions of each adapter. Sample applications are installed in
STREAMBASE_HOME/sample/adapter/embedded.
Sample EventFlows
This group of samples includes EventFlow applications that focus on specific operators and data constructs. business problems, and on configuration steps.
- The Authentication Sample demonstrates what happens when you enable StreamBase authentication and then try to use several
sb*StreamBase commands, such assbadmin shutdown. - Best Bids and Asks Sample Shows an example of a common stock trading application that tracks the highest bid price and lowest ask price for each stock.
- BollingerBand Sample Shows an example of a common analytical tool that provides a relative definition of high and low bands in securities trading.
- The Cluster Sample Shows how the processing of operators in a StreamBase application can be distributed over multiple machines (using the concurrency option for module references or operators, and cluster features). To keep the scope simple, we only use two machines in this sample. However the feature supports the use of many more machines in a cluster, provided they are running the same version of StreamBase, the same operating system type, and the same architecture.
- Compliance Sample Shows an example of a common stock fund application, where the StreamBase operators are used to ensure that funds are in compliance with their business requirements.
- Counter Sample Demonstrates how to implement a counter to generate sequence numbers.
- FeedProc Sample Shows an example of application that processes financial tick data from three financial feeds, performing various useful computations on the data.
- MACD Sample Shows an example of a momentum indicator: a program that follows trends and shows the relationship between two moving averages of prices.
- Operator and Data Construct Samples Demonstrate how to include individual operators and data constructs in StreamBase applications.
StreamBase Tutorials
The First Application Sample Steps through the mechanics of using StreamBase Studio, defining a simple application, submitting generated test data to it, and observing the results. This is the same application you may have defined already while following the tutorial in the Getting Started Guide.
StreamBase Debugger TutorialWalks you through a debugging session and examines tuples in the Compliance sample.
Installed Locations
By default, the StreamBase samples are installed under:
| UNIX | Windows |
|---|---|
/opt/streambase/sample/... |
C:\Program Files\StreamBase Systems\StreamBase\sample\... |
| Note: You can import the locally installed samples in StreamBase Studio. For more information, please see the next section. | |
Rebuilding Samples on Windows
A number of StreamBase samples, such as compliance and buffering, have C++ and Java code that can be modified and rebuilt. In order to rebuild the C++ executables and Java JAR files, Microsoft Visual Studio must be configured as follows:
- Add the following StreamBase
includedirectories to the list of "Include files" in "Tools > Options > Projects > VC++ Directories":<StreamBase-install-directory>\include
By default, StreamBase is installed in the following folder on Windows:
C:\Program Files\StreamBase Systems\StreamBase
- Add the Sun SDK or JDK's
binfolder to the list of "Executable files".For example, if JDK 1.5.0_06 is installed in the folder
C:\jdk1.5.0_06, add the following folder to the list:C:\jdk1.5.0_06\bin
