Creating a Feed Simulation

Purpose

So far we have created an application and started it in StreamBase Studio. Our goal is to enqueue some data to it and view its output, and the application is now waiting for tuples to process.

If you performed the Getting Started Cheat Sheet, you enqueued data manually, one tuple at a time. In this tutorial we will learn a more sophisticated method: using a feed simulation that automatically enqueues test data. A feed simulation can enqueue data at faster rates and in different ways than manual data.

The StreamBase Feed Simulator 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. It generates tuples choosing values from a list that you provide.

Creating the Feed Simulation

  1. 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. To add a simulation to the list, right-click in the list area and choose New Feed Simulation.

  3. In the New StreamBase Feed Simulation wizard:

    1. Enter or select the name of your application's parent folder, MyFirstApp.

    2. Enter a name for your simulation. Let's call it firstapp-enum.sbfs:

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

      The new file appears in the Feed Simulations view. (You will also see it in your Package Explorer, the next time you open the SB Authoring perspective.)

  4. Your new file opens in the Feed Simulation Editor's Stream Configurations tab.

    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 Add to define your simulation stream.

  5. In the Add Simulation Stream dialog, Enter TradesIn as the stream name. The simulation stream's name must match the name of the application input stream that it will enqueue data to.

  6. Define the fields in the simulation stream. You can add only fields whose names and data types match fields in the associated input stream. We could add the fields manually, but let's use an easier way: click the Copy Schema From Existing Component button.

    1. Choose the option, From schemas in any workspace application.

    2. In the Project field, choose the current project, MyFirstApp.

    3. In the Application field, choose your application file (either the sbapp or ssql version).

    4. Under Copy schema from, select the TradesIn input stream. The fields from that stream's schema are loaded in the Schema Preview table:

    5. Click OK.

  7. In the Add Simulation Stream dialog, the Fields table is now loaded with the fields from the TradesIn schema. Click OK.

  8. Back in the Feed Simulation Editor, we will change the default behavior: instead of generating random values, we want to model a set of specific values. Choose the Custom option and click Customize Fields.

  9. In the Customize Fields dialog, click in the undefined Customized Value column for each field and define it as follows:

    symbol
    1. Choose the Enumerated option from the drop-down control.

    2. Choose the option, 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
    quantity
    1. Choose the Enumerated option again.

    2. Click the Add Row button six times.

    3. Choose the option, The following values.

    4. Enter these values and weights:

      Value Weight
      30000 0.10
      10000 0.10
      100 0.20
      200 0.20
      400 0.20
      1000 0.20

    The weights determines the relative frequency of values generated. By default, all weights are one, meaning all values are equally likely to appear.

    Click OK to dismiss the dialog.

  10. Press Ctrl-S to save your feed simulation.

Note

To see the source code of your new feed simulation, open the editor's firstapp-enum.sbfs tab.

Summary and Next Steps

In this topic, you learned how to create a feed simulation. Click Next to go to use your feed simulation with your running application.

Back to Top ^