LiveView Project Tutorial

Introduction

This topic takes you through the steps to create a new TIBCO Live Datamart 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 Live Datamart project, and view the results in TIBCO LiveView™ 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. Select the check box for Create a LiveView Data Table.

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

  7. Click Finish. This triggers several actions:

    • A folder for the my-first-liveview-project appears in the Package Explorer view.

    • The LiveView Project Viewer opens in the Editor space in Studio's upper right, showing an empty canvas.

    • On top of the empty Project Viewer, the New Data Table wizard opens, which is described in the next section.

    • On top of the wizard, the New StreamBase Project Created dialog appears; read the dialog and select the Do not show this again check box.

  8. Continue to the next section

Using the New LiveView Data Table Wizard

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 continues the New Project steps in the previous section to configure a LiveView data table with three fields.

  1. The New Data Table wizard is still open from the last step in the previous section. (If not, open it with FileNewTIBCO LiveView Data Table, or right-click the empty Project Viewer canvas and select New Data Table.)

  2. Enter Orders in the Table Name field.

  3. In the Interface/Application field, define all fields locally is selected by default. In the Schema 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.

  4. Click Next to open the next page of the wizard.

  5. Make the Symbol field the primary key for this table in one of the following 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.

  6. Click Finish. This adds Orders.lvconf to the project in the Package Explorer view, and places a green Data Table icon labeled Orders on the Project Viewer canvas.

  7. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on the Mac to save the current project state.

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

Generate an EventFlow Module to Feed the Data Table

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

  1. On the LiveView Project Viewer's canvas, right-click and select Data Source. The New LiveView Data Source wizard opens.

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

  3. In the EventFlow™ Application file name field, change the default-entered DataSource to OrdersDataSource.

  4. Leave the Create a sample feed simulation check box selected.

  5. Use the drop-down menu selector in the Target Table field to select Orders.

  6. Click Finish. This triggers several actions:

    • Three new files are added to the project in the Package Explorer view:

      OrdersDataSource.sbapp
      OrdersDataSource.sblayout
      Orders.sbfs
    • A purple Data Source icon is added to the Project Viewer, with an arrow linking it to the Data Table icon.

    • The wizard creates two StreamBase interface files, places them in a new lv-interfaces subfolder, and automatically adds this subfolder to the project's resource search path.

      These interface files contain the schemas for the Orders data table's input and output streams. Using interface files allows the schemas to be used and reused efficiently throughout the project.

    • Studio opens the EventFlow Editor for the newly created module OrdersDataSource.sbapp.

  7. In the EventFlow Editor:

    1. Double-click the DataOut icon, select the General tab in Properties view, and make sure the check box for Always expose Stream for Dequeue is selected.

    2. Study the Data Source application generated for you. Notice that it uses a Feed Simulation Input adapter to send generated tuples with the correct schema to its DataOut stream, which feeds into the Orders Data Table's input stream.

    3. Double-click the InputAdapter icon, select the Adapter Properties tab of the Properties view, and notice that the generated file Orders.sbfs is preselected in the Feed Simulation File field. Notice that the feed simulation is configured to start automatically when the containing EventFlow module is started.

      This feed simulation file uses the Default generation method, in which random string and numeric values are generated as input data. After you have tested the generated Live Datamart application, you can come back and specify more precise customized data for each input field.

  8. Use FileSave, Ctrl+S on Windows and Linux, or Command+S on the Mac to save the current project state.

Test the EventFlow Module

This optional step is only to provide visual confirmation that the data source EventFlow module receives correctly formatted data from its connected feed simulation adapter.

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

  2. In the SB Test/Debug perspective, observe the Application Output view. 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.

    Notice that the DataOut stream also shows five LiveView-internal fields, usually with null values, in addition to the Symbol, Price, and Quantity fields you configured.

  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 Live Datamart project on an instance of LiveView Server.

  1. For clarity, close the EventFlow Editor session that is editing the OrdersDataSource.sbapp module.

  2. Run the LiveView project in one of several ways:

    1. In the LiveView Project Viewer, click the green Run button in the upper right, next to the Help button.

    2. Select the my-first-liveview-project project in the Package Explorer view. Right-click and select Run AsLiveView Project.

    3. Select any of the lvconf files in the my-first-liveview-project project in the Package Explorer view. Right-click and select Run AsLiveView Project.

    4. Select the my-first-liveview-project project in the Package Explorer view. From Studio's top-level menu, select RunRun AsLiveView Project.

  3. The Console view shows several messages as Live Datamart Server compiles the project and starts. This startup process can take several minutes, depending on the configuration of your computer.

  4. When you see the message All tables have been loaded in the Console view, you are ready to connect a client application to this server instance to view the stream of data flowing through this project's data table.

Connect a LiveView Client

To see the data flowing through your running Live Datamart data table, you must connect a LiveView client to the server and use it to run a query using the LiveQL query language. The simplest query for this application is

select * from Orders;

or perhaps

select * from Orders limit 50;

The following LiveView Client applications are provided with Live Datamart or as related downloads:

  • lv-client, a command line utility, is included with Live Datamart.

  • The LiveView web monitor interface is built into Live Datamart server, and accessible from a web browser.

  • TIBCO LiveView™ Web is a web browser based client interface licensed and downloaded as a related product.

  • TIBCO LiveView™ Desktop is a Windows or Mac OS X desktop client application licensed and downloaded as a related product.

In addition, you can write LiveView clients of your own using the provided Java or JavaScript Client APIs.

The following subsections give brief instructions to connect each of these client types.

Connect and Run lv-client

Follow these steps:

  1. Open a StreamBase Command Prompt on Windows or a Terminal session on OS X. Make sure the Terminal session is configured with the sb-config --env command as described in Steps to Install StreamBase on macOS.

  2. With the LiveView application running as described above, enter the following command at the prompt:

    lv-client "select * from Orders limit 30;"

    You may need to specify a LiveView URL to the running server:

    lv-client -u lv://localhost:10080 "select * from Orders limit 30;"

Connect the Web Monitor Interface

Follow these steps:

  1. With LiveView Server running, connect a web browser to:

    http://localhost:10080/lv/monitor
  2. Click the Run Queries link at the top right.

  3. Double-click to select the Orders entry in the Table List. This places the default query in the query field: select * from Orders

  4. Click either the Snapshot or Continuous buttons.

  5. When done, click the Stop button.

Connect and Run LiveView Web

To use the LiveView Web client, you must download and install it. Installing is usually a simple matter of the following steps:

  • If your LiveView project is running, stop it by clicking the read and blue button in Studio's top-level toolbar.

  • Create a new folder in your my-first-liveview-project folder. The new folder's name must be lv-user-webapps.

  • Drag the lvweb.war file from the LiveView Web distribution into the lv-user-webapps folder.

  • Select the project folder in the Package Explorer view, right-click and select Refresh.

  • Restart LiveView Server on your project as described above.

With LiveView Web installed, use it to connect to your running server with the following steps:

  1. With LiveView Server running, connect a web browser to:

    http://localhost:10080/lvweb
  2. Click New Page to create a new query page, perhaps named Orders Table.

  3. Click New Card to create a query card.

  4. In the dark blue section on the right, provide a title for your query card to replace the [Untitled] label, such as Orders Table -- All.

  5. Still on the right, open the Query Builder section.

  6. From the Choose a table control, select Orders.

  7. The default query select * from Orders is entered for you in the Query field.

  8. Click Save Changes. This populates the Orders Table -- All card on the left.

  9. Click the X in the upper right of the dark blue configuration area to close it.

  10. Grab the bottom right corner of the Orders Table -- All card to resize it.

  11. When done, close the browser tab. LiveView Web preserves your configured table in the project settings in Studio.

Connect and Run LiveView Desktop

To use the LiveView Desktop client, you must download and install it. Once installed, run LiveView Desktop with the following steps:

  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 folder with any name.

    4. Click OK.

  3. When LiveView Desktop connects to the server, the Orders table is opened in a data grid view on the right side, running with the default query select * from Orders.

  4. If you see only the Tables view by default, double-click the Orders table in the Tables View to get a look at the incoming data flowing through the table.

  5. Experiment with different queries and different visualizations of the data.

  6. When done, exit LiveView Desktop.

Close and Shut Down

When done:

  • Close and exit your LiveView client connection.

  • 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 now configured and run a simple LiveView project, and viewed its data with a LiveView client application.