Contents
This sample, firstapp.sbapp
, demonstrates a StreamBase
application with one notable characteristic: it is easy to create. You may have
already created it yourself, if you performed the tutorial in the Getting Started Guide.
The application is modest in functionality, but building it teaches you some important fundamentals including:
-
The general design process of defining input streams, schemas, operators, and output streams
-
Adding and connecting components in an EventFlow
-
Typechecking operators to ensure that streaming data can flow through the application without errors
-
Features of the SB Authoring and SB Test/Debug perspectives
-
Running the application in StreamBase Studio
-
Creating a feed simulator to enqueue test data automatically to the running application
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
> . -
Enter
fir
narrow the list of options. -
Select The Getting Started Guide tutorial from the Applications category.
-
Click
.
StreamBase Studio creates a project for the sample.
To start this sample:
-
In the Project Explorer view, open the sample you just loaded.
-
Open the
src/main/eventflow/
folder.packageName
-
Open the
firstapp.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
When done, press F9 or click the Terminate EventFlow Fragment button.
The server is ready to receive input. See the following sections to manually enqueue data into this sample. For additional enqueuing instructions, see the Getting Started Guide.
To enqueue data manually in Studio:
-
Open the Manual Input view.
-
In the Output Streams view, make sure that the Output stream option is set to
All streams
. -
Enter
IBM
in the symbol field, and10000
in the quantity field. -
Click
to send this tuple to the application. -
Observe the output in the Output Streams view:
Because the quantity satisfies the Filter predicate, your tuple is passed through on the BigTrades stream.
-
Enter
100
in the quantity field and click again. -
Observe that this time, your output appears in the AllTheRest output stream.
Why? Because the quantity is below the predicate's threshold of 10000.
-
Enter different values above and below the threshold, and see how your application responds. Try entering an invalid quantity such as
alpha
.
To enqueue test data using any of the three feed simulations:
-
Open the Feed Simulations view.
-
In the Feed Simulations view, select a feed simulation.
-
Click
.The Input Streams view displays generated tuples enqueued from your Feed Simulation. At the same time, the Output Streams view begins displaying tuples on the two output streams.
-
If you chose
firstapp-enum.sbfs
, let it run for five or ten seconds, then click (otherwise it runs continuously). The other two feed simulators run to completion, but feel free to stop them when you have enough data.Note that stopping the feed simulation does not stop the application.
-
Observe the results in the Input Streams and Output Streams views. (If necessary, resize the views so that you can see their contents clearly.)
Tip
Click a row to display its field summary below the list, as shown in the next figure.
You should see trades values that are both above and below the threshold of 10000 that was set in your Filter operator.
-
When done, press F9 or click the Terminate EventFlow Fragment button.
In addition to the application, the installed First Sample includes two additional feed simulations. Thus, there are three simulations in total, each demonstrating a different way of modeling test data:
- firstapp-enum.sbfs
-
Also featured in the tutorial, generates values from a list of symbols and quantities, in random order. The enumeration also specifies the weights of the quantities.
- firstapp-trace1.sbfs
-
Uses an external comma-separated value data file,
firstapp-trace1.csv
, to explicitly list the order and values of tuples. - firstapp-trace2.sbfs
-
Uses values specified in another external comma-separated value data file,
firstapp-trace2.csv
, and also uses relative timestamps to control the rate of enqueuing.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
studio-workspace
/sample_firstapp
See Default Installation
Directories for the default location of studio-workspace
on your system.