Creating a Feed Simulation


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.

Creating the Feed Simulation

  1. 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.

  2. From Studio's top-level menu, select FileNewStreamBase Feed Simulation.

  3. In the New StreamBase Feed Simulation wizard:

    1. Select the name of your application's parent folder, MyFirstApp.

    2. Enter a name for your simulation: firstapp-enum.sbfs

      Click Finish to create the new feed simulation and close the wizard.

  4. 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 Copy from Stream/Named Schema to borrow the stream's schema from the application.

  5. In the Stream Selection dialog, open the MyFirstApp project, then MyFirstApp.sbapp module. Select the TradesIn stream and click OK.

  6. 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.

  7. 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 Customize Fields.

  8. In the Customize Fields dialog, define each field as follows:

    1. In the Generation Method column, select Enumerated from the drop-down control.

    2. Select the option at the bottom of the dialog labeled The following values.

    3. Click the Add Row 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
    1. In the Generation Method column, again select Enumerated from the drop-down control.

    2. Again select the The following values option.

    3. Click the Add Row button six times.

    4. Choose the option, The following values.

    5. 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 OK to close the dialog.

  9. Press Ctrl+S (Windows) or command+S (Mac) to save your feed simulation.

Next Step

Click Next to go to use your feed simulation with your running application.

Back to Top ^