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
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 StreamBase Application (Default Launch)
button. (Not the Run button.) This
opens the 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. -
Click → (F9).
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
