LiveView Project Tutorial

Introduction

This topic takes you through the steps to create a new TIBCO LiveView project, create and configure a LiveView data table, generate an EventFlow application module that will feed the LiveView table, and create a feed simulation to send data into the EventFlow table. The steps go on to run the LiveView project, and view the results in TIBCO StreamBase Desktop.

This tutorial's project has the following characteristics:

  • Has a single, three-column LiveView data table configured to contain stock symbol, price, and quantity values.

  • Has a wizard-generated TIBCO StreamBase EventFlow application that uses a feed simulation adapter to accept input from a StreamBase feed simulation, then emits that data to an output stream.

  • Uses the LiveView Configuration Editor to create all required LiveView tables and features.

Create a New Project

Use the following steps to create a new project to contain the work of this tutorial:

  1. Open StreamBase Studio.

  2. In Studio's SB Authoring perspective, select FileNewStreamBase Project. The New StreamBase Project dialog opens.

  3. In the New StreamBase Project dialog, enter a name for the project. This example uses my-first-liveview-project.

  4. Clear the check box for Create empty EventFlow Application file.

  5. Keep the default selections for the check boxes Use default location, Maintain project settings, and the Java Build Path Options settings (with those check boxes selected).

  6. Click Finish. A folder for the my-first-liveview-project appears in the Package Explorer view.

The next sections configure a number of LiveView objects:

  • A data table container for stock trade information.

  • An application table that points to the StreamBase EventFlow application used as the source for data to be streamed into the stock trade table.

Configure a LiveView Data Table

LiveView data tables are containers for streaming data. They can receive incoming streamed data from multiple sources, including EventFlow applications, external data sources, and other LiveView tables. This tutorial configures a data table with three fields.

  1. Right-click the project folder and select NewTIBCO LiveView Configuration File.

  2. Select my-first-liveview-project for the parent folder.

  3. Enter Orders for the LiveView Configuration file name.

  4. Select the Data Table radio button.

  5. Click Finish. The new configuration file opens in the LiveView Configuration File Editor in Studio.

    The Editor view's title bar shows errors because the table has not yet been configured.

  6. Select the Use a Private Schema radio button.

  7. In the field grid section, click the green plus sign to add the following fields to the grid:

    Field Name Type
    Symbol string
    Price double
    Quantity int

    The Description column for each field is optional.

  8. Select the Indices tab at the bottom of the LiveView Configuration Editor view. Make the Symbol field the primary key for this table in either of two ways:

    • In the Available Fields list, select Symbol, then click the right-pointing arrow next to the Index Fields label.

    • In the Available Fields list, select Symbol then drag it to the Index Fields area with the mouse.

    • Double-click Symbol.

  9. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on Mac to save the Orders.lvconf file.

  10. If the Configuration Editor reports errors, correct the affected fields and re-save the file.

The data table is now configured and ready to receive data.

Generate an EventFlow Module to Feed the Data Table

The LiveView plug-ins for StreamBase Studio provide a wizard that can generate a StreamBase EventFlow module with output stream schemas pre-configured to match a particular LiveView data table's configuration. Follow these steps:

  1. Create a sub-folder for the EventFlow application that will populate the incoming data stream.

    1. Select FileNewFolder.

    2. Select my-first-liveview-project for the parent folder.

    3. Enter OrdersDataSource for the folder name.

    4. Click Finish.

  2. Add the new subfolder to this project's module search path. This is necessary to support a later step in the process.

    1. Select my-first-liveview-project in the Package Explorer view.

    2. From Studio's top-level menu, invoke ProjectProperties (or right-click and select Properties). This opens the project properties dialog.

    3. From the lefthand contents column, select StreamBaseModule Search Path.

    4. Click Add and select the OrdersDataSource folder.

    5. Click OK twice to exit the dialog.

  3. Generate a data-source application with the correct schemas to match the Orders table. You can do this with the EventFlow application wizard, which will create a template EventFlow module as well as a StreamBase interface file with all the right schemas.

    1. Select FileNewStreamBase EventFlow™ Application. The New StreamBase EventFlow Application dialog opens.

    2. Select my-first-liveview-project/OrdersDataSource for the parent folder.

    3. Enter Orders for the EventFlow module's file name. Make the name match the name of the lvconf file's basename for the table you are matching.

    4. Select the check box for Configure for use with TIBCO LiveView.

    5. Click Next.

    6. Select Data Source from the Type of Application pull-down menu. Since this project has only one data-table, the wizard automatically selects Orders for the Table name.

    7. Click Finish. StreamBase Studio opens the OrdersDataSource/Order.sbapp file in the editor view.

    The EventFlow application wizard creates an interface file to store the schemas for the Orders table, and an interface file for the generated Order.sbapp module that imports the schemas interface. Both generated interface files are placed in the lv-interfaces folder, and that folder is added to the project's module search path. LiveView uses the schema interface to create a data stream with the correct schema for the Orders table.

  4. On the canvas for Orders.sbapp, double-click the DataOut icon in the editor, select the General tab in Properties view, and make sure the check box for Always expose Stream for Dequeue is selected.

  5. Select the Schema tab in the Properties view. Confirm that the generated schema for the DataOut stream contains the fields shown in the following image:

    Notice that this output stream's schema name is OrdersDataInSchema. This is the required schema that matches the schema of the DataIn stream for sending data into the Orders table.

  6. Now, you can create the data to populate the data stream. This example uses a StreamBase Input Feed Simulation Adapter with a custom feed simulation. To add the feed simulation adapter to your application, follow these steps:

    1. Open OrdersDataSource/Orders.sbapp in the EventFlow Editor view.

    2. Drag the Adapters, Java Operators icon from the Palette view onto the editor canvas. The Insert an Operator or Adapter dialog opens.

    3. Enter feed into the filter field to narrow the range of options.

    4. Select Feed Simulation from the Global category and click OK.

    5. Connect the lower output port of the Adapter to the input port on the DataOut stream.

    The adapter appears red and the module does not yet pass typechecking. This is because the Feed Simulation adapter needs a feed simulation, defined next.

  7. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on OS X to save the Orders.sbapp file, despite it not yet passing typechecking.

Define a Feed Simulation

We now create a feed simulation and connect it to the Feed Simulation adapter in Orders.sbapp. Follow these steps:

  1. Select FileNewFeed Simulation. This opens the New StreamBase Feed Simulation wizard.

  2. Select my-first-liveview-project as the parent folder, specify the file name Orders, and click Finish. This creates a file named Orders.sbfs and opens it in the editor.

  3. Enter a description in the Simulation Description field. This example uses Simple data feed.

  4. In the Simulation Streams section, click Copy from Stream/Named Schema.

  5. Select the schema OrdersDataInSchema from the interface file in my-first-liveview-project/lv-interfaces/OrdersSchemas.sbint.

  6. Next, select the Custom generation method and click the Customize Field button to open the Customize Fields dialog. We will use this dialog to specify the range of values for the feed simulation to generate for each field. For each field, select from the Generation Method drop-down list as shown in the following table.

    Field Generation Method Values Effect of This Setting
    PublisherID Constant feedsim A string to identify the data source.
    PublisherSN Incremented 0 to 10,000, start value 0, increment 1, null probability 0.0, Reset values selected. Generate an incrementing serial number.
    CQSDataUpdatePredicate Constant null Set to null; non-null would update all matching rows of a table.
    CQSDelete Constant false This field is only used to delete table rows.
    CQSReferredCount Constant null Set to null; the system might use this field internally.
    Symbol Enumerated Generate 20 random values with equal weights. Generates 20 random strings.
    Price Uniform 1.0 to 500.0, probability of generating null 0.0. Generates doubles in a uniform random distribution.
    Quantity Uniform 1 to 1500, probability of generating null 0.0. Generates integers in a uniform random distribution.
  7. When done, click OK.

  8. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on Mac to save the Orders.sbfs feed simulation file.

Next, re-open the Orders.sbapp EventFlow application to tell it about the new feed simulation file:

  1. Re-open OrdersDataSource/Orders.sbapp in the EventFlow Editor view.

  2. Double-click the InputAdapter icon to open its Properties view.

  3. In the Adapter Properties tab, use the Choose button to select Orders.sbfs for the Feed Simulation File field.

  4. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on Mac to save the Orders.sbapp EventFlow module file, which now passes typechecking.

Configure a LiveView Data Source Table

Next, we configure a LiveView data source table that will call the EventFlow module data source on behalf of the Orders table.

  1. Create a LiveView configuration for a data source table, OrdersDataSource, which will call the EventFlow data source configured above. This step creates an lvconf that accesses the subfolder where the applications are stored, so that successive project tables can reference this lvconf rather than having to reference individual EventFlow applications.

    1. Select FileNewTIBCO LiveView Configuration File. The New TIBCO LiveView Configuration File dialog opens.

    2. Select my-first-liveview-project for the parent folder.

    3. Enter OrdersDataSource.lvconf for the LiveView Configuration file name.

    4. Select the Application radio button.

    5. Click Finish. This opens the new configuration file in the LiveView Configuration File Editor in Studio.

      When using the LiveView Configuration File Editor:

      • Hover the cursor over each field to see a tooltip explanation for that field.

      • You can switch to the Source tab to see the generated lvconf file in XML form.

      • Watch for messages at the top of the Editor view and in the margins of the Source view that warn of configuration errors or conflicts.

    6. In the Application field, use the drop-down control to select OrdersDataSource/Orders.sbapp.

    7. Save the table with Ctrl+S (Command+S on the Mac).

  2. Add the reference from OrdersDataSource to Orders. The Orders table will use the OrdersDataSource table as an intermediary for communicating with the EventFlow data source application.

    1. In the Package Explorer view, double-click the Orders.lvconf entry to re-open the LiveView Configuration File Editor.

    2. Select the Data Sources tab at the bottom of the editor view.

    3. Select the Application check box. This opens new fields on the right.

    4. In the Application Reference field, use the drop-down control to select OrdersDataSource.

    5. In the Output Stream field, type the name of the output stream in Orders.sbapp, which is DataOut.

    6. Save the table with Ctrl+S (Command+S on the Mac).

Test the EventFlow Module

This step is to make sure the data source EventFlow module receives the correct data from its feed simulation.

  1. Run the application. Right-click in the editor canvas or on the orders.sbapp file in the Package Explorer view and select Run AsStreamBase Application.

  2. Observe the Application Output tab. Look for the outgoing data stream to be automatically populated by the associated feed simulation.

  3. Click on a row in the application output tab and examine the tuple contents. Each tuple shows a generated value for Symbol, Price, and Quantity fields, in addition to the required fields.

  4. When done, press F9 or click the red Stop StreamBase Application button in Studio's top-level toolbar.

Run the LiveView Application

Now we are ready to compile and run the LiveView project on an instance of LiveView Server.

  1. Select my-first-liveview-project in the Package Explorer view.

  2. Right-click and select Run AsLiveView Project. The Console view shows several messages as the LiveView Server compiles the project and starts. This startup process can take several minutes, depending on the configuration of your computer.

  3. When you see the message All tables have been loaded in the Console view, you are ready to start LiveView Desktop.

Run LiveView Desktop

Run the LiveView Desktop client to connect to the locally-running LiveView Server, and to query and view the results.

  1. Start LiveView Desktop with one of the following methods:

    • On Windows, invoke StartAll ProgramsTIBCOLive Datamart n.mLiveView Desktop n.m.

    • On Mac OS X, use Spotlight or Launchpad to locate and invoke the app named liveview.

    • On Linux, run the following command:

      /opt/tibco/sb-cep/n.m/liveview/desktop/liveview &
      

    Any of these methods opens the Connect to LiveView dialog.

  2. In the dialog:

    1. Type any username and no password.

    2. In the Server field, enter localhost.

    3. Specify a Local workspace with any name.

    4. Click OK.

  3. When LiveView Desktop connects to the server, you see only the Tables view by default. Double-click the Orders table to get a look at the incoming data flowing through the table.

Close and Shut Down

When done:

  • Close LiveView Desktop.

  • Stop LiveView Server with Ctrl+F9 (Command+F9 on the Mac), or by clicking the red and blue button in StreamBase Studio's top-level toolbar.

You have configured and run a simple LiveView project.