Contents
This sample demonstrates the benefit of using buffering in the StreamBase
client. The sample application contains an aggregate that calculates the average of a
double field for all tuples processed.
For related information about enabling buffering in producer or enqueue clients, see the topic Creating Clients in the API Guide.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, click → .
-
Select this application from the Client APIs list.
-
Click OK.
StreamBase Studio creates a project for this sample.
By default, the sample files are installed in:
-
On Windows:
C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\operator -
On UNIX:
/opt/streambase/sample/operator
When you load the sample into StreamBase Studio, Studio copies the
sample project's files to your Studio workspace. StreamBase Systems
recommends that you use the workspace copy of the sample, especially on UNIX, where
you may not have write access to /opt/streambase. In
the default installation, the path to this sample in your Studio workspace is:
UNIX: ~/streambase-studio-n.m-workspace/sample_operator Windows XP: C:\Documents and Settings\username\My Documents\StreamBase Studion.mWorkspace\ sample_operator Windows Vista: C:\Users\username\Documents\StreamBase Studion.mWorkspace\ sample_operator
The Buffering Sample consists of:
-
A StreamBase application,
simple.sbapp -
Enqueue programs (binaries) that use the StreamBase Java and C++ Client APIs.
-
Java and C++ source code for the Enqueue programs.
-
Either Microsoft Visual Studio .Net solution and project files (Windows) or a
Makefile(UNIX) that can be used to build all of the sample source code. (In the Visual Studio files, the paths to find StreamBaseincludefiles and libraries are configured to run from the installation directory.)
To run this sample:
-
In the Package Explorer, double-click to open the
simple.sbappapplication. Make sure the application is the currently active tab in the EventFlow Editor. -
Click the
Run button. This opens the
SB Test/Debug perspective and starts the application.
-
Add
sbclient.jarto your CLASSPATH. The JAR can be found in the lib directory of your StreamBase installation. Add the sample directory to your CLASSPATH as well, so that java can findEnqueuer.class. -
Dequeue from the output stream with the following command:
sbc dequeue & -
To run the Java Enqueuer, enter:
java Enqueuer -b 1 -
After a delay, you should see the number of tuples enqueued and the number of tuples enqueued per second.
-
Run the Enqueue program again using
-b 10instead of-b 1and observe the improvement. -
When done, press F9 or click the
Stop Running Application button.
To run this sample:
-
Launch a StreamBase Server on the sample application:
sbd simple.sbapp -
Add
sbclient.jarto your CLASSPATH. The JAR can be found in the lib directory of your StreamBase installation. Add the sample directory to your CLASSPATH as well, so that java can findEnqueuer.class. -
Dequeue from the output stream with this command:
sbc dequeue -
To run the Java Enqueuer:
java Enqueuer -b 1 -
To run the C++ Enqueuer:
Enqueuer -b 1 -
After a delay, you should see the number of tuples enqueued and the number of tuples enqueued per second.
-
Run the Enqueue program again using
-b 10instead of-b 1and observe the improvement. -
Command line options can be given to each of the enqueuers. The following commands will display those options:
java Enqueuer -hEnqueuer -h
