Contents
The goal of this topic is to create a StreamBase feed simulation that we can use to send generated date to the application's input stream.
The StreamBase feed simulation feature is highly customizable, and you can learn more about its many features in the Test/Debug Guide. Several feed simulations are provided with the firstapp
sample application that is installed with StreamBase, as described in First Application Sample. In this topic we will recreate one of them: firstapp-enum
.sbfs, which generates tuples, choosing values from a list that you provide.
-
Switch to the SB Test/Debug perspective, and open the Feed Simulations view. The view contains a list of existing feed simulations in the project (your list may be empty at this point). Below the list are control buttons to run and stop a selected feed simulation, and a slide control that lets you change the rate at which tuples are submitted.
-
From Studio's top-level menu, select
→ → . -
In the New StreamBase Feed Simulation wizard:
-
Select the name of your application's parent folder,
MyFirstApp
. -
Enter a name for your simulation:
firstapp-enum.sbfs
Click
to create the new feed simulation and close the wizard.
-
-
This open the Feed Simulation Editor.
In the Simulation Streams area, you must define a stream for the feed simulation that can enqueue data to the application's input stream. Click to borrow the stream's schema from the application.
-
In the Stream Selection dialog, open the
MyFirstApp
project, thenMyFirstApp.sbapp
module. Select theTradesIn
stream and click . -
This places the TradesIn stream into the Simulation Streams area. Open the arrow symbol on left of the stream's name to see the schema of the imported stream.
-
The Feed Simulation Editor's default behavior is to generate random values for each field in the input stream. We instead want to model a set of specific values. In the Generation Method section, select the Custom option and click .
-
In the Customize Fields dialog, define each field as follows:
- symbol
-
-
In the Generation Method column, select from the drop-down control.
-
Select the option at the bottom of the dialog labeled The following values.
-
Click the
button four times, and enter these values and weights in the new rows:Value Weight NKE 1.0 CMG 2.0 GMCR 1.0 FSLR 2.5
-
- quantity
-
-
In the Generation Method column, again select from the drop-down control.
-
Again select the The following values option.
-
Click the
button six times. -
Choose the option,
The following values
. -
Enter these values and weights:
Value Weight 30000 0.1 10000 0.1 100 0.2 200 0.2 400 0.2 1000 0.2
-
The weights determines the relative frequency of values generated. By default, all weights have a value of one, meaning all values are equally likely to appear. A fractional weight of 0.2 means that the specified value is to appear 20% of the time.
Click
to close the dialog. -
Press Ctrl+S (Windows) or command+S (Mac) to save your feed simulation.