Contents
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.
Use the following steps to create a new project to contain the work of this tutorial:
-
Open StreamBase Studio.
-
In Studio's SB Authoring perspective, select → → . The New StreamBase Project dialog opens.
-
In the New StreamBase Project dialog, enter a name for the project. This example uses
my-first-liveview-project
. -
Clear the check box for Create empty EventFlow Application file.
-
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).
-
Click
. A folder for themy-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.
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.
-
Right-click the project folder and select
→ . -
Select
my-first-liveview-project
for the parent folder. -
Enter
Orders
for the LiveView Configuration file name. -
Select the
radio button. -
Click
. 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.
-
Select the Use a Private Schema radio button.
-
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.
-
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
.
-
-
Use Ctrl+S on Windows and Linux, or Command+S on Mac to save the
→ ,Orders.lvconf
file. -
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.
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:
-
Create a sub-folder for the EventFlow application that will populate the incoming data stream.
-
Select
→ → . -
Select
my-first-liveview-project
for the parent folder. -
Enter
OrdersDataSource
for the folder name. -
Click
.
-
-
Add the new subfolder to this project's module search path. This is necessary to support a later step in the process.
-
Select
my-first-liveview-project
in the Package Explorer view. -
From Studio's top-level menu, invoke Properties). This opens the project properties dialog.
→ (or right-click and select -
From the lefthand contents column, select
→ . -
Click
and select the OrdersDataSource folder. -
Click
twice to exit the dialog.
-
-
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.-
Select
→ → . The New StreamBase EventFlow Application dialog opens. -
Select
my-first-liveview-project/OrdersDataSource
for the parent folder. -
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. -
Select the check box for Configure for use with TIBCO LiveView.
-
Click
. -
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. -
Click
. StreamBase Studio opens theOrdersDataSource/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 thelv-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. -
-
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. -
Select the Schema tab in the Properties view.
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.
-
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:
-
Open
OrdersDataSource/Orders.sbapp
in the EventFlow Editor view. -
Drag the Adapters, Java Operators icon from the Palette view onto the editor canvas. The Insert an Operator or Adapter dialog opens.
-
Enter
feed
into the filter field to narrow the range of options. -
Select Feed Simulation from the Global category and click
. -
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.
-
-
Use Ctrl+S on Windows and Linux, or Command+S on OS X to save the
→ ,Orders.sbapp
file, despite it not yet passing typechecking.
We now create a feed simulation and connect it to the Feed Simulation adapter in
Orders.sbapp
. Follow these steps:
-
Select New StreamBase Feed Simulation wizard.
→ → . This opens the -
Select
my-first-liveview-project
as the parent folder, specify the file nameOrders
, and click . This creates a file namedOrders.sbfs
and opens it in the editor. -
Enter a description in the Simulation Description field. This example uses
Simple data feed
. -
In the Simulation Streams section, click .
-
Select the schema OrdersDataInSchema from the interface file in
my-first-liveview-project/lv-interfaces/OrdersSchemas.sbint
. -
Next, select the Custom generation method and click the 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. -
When done, click OK.
-
Use 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:
-
Re-open
OrdersDataSource/Orders.sbapp
in the EventFlow Editor view. -
Double-click the
InputAdapter
icon to open its Properties view. -
In the Adapter Properties tab, use the Choose button to select Orders.sbfs for the Feed Simulation File field.
-
Use Ctrl+S on Windows and Linux, or Command+S on Mac to save the
→ ,Orders.sbapp
EventFlow module file, which now passes typechecking.
Next, we configure a LiveView data source table that will call the EventFlow module data source on behalf of the Orders table.
-
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.
-
Select New TIBCO LiveView Configuration File dialog opens.
→ → . The -
Select
my-first-liveview-project
for the parent folder. -
Enter
OrdersDataSource.lvconf
for the LiveView Configuration file name. -
Select the Application radio button.
-
Click
. 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.
-
-
In the Application field, use the drop-down control to select
OrdersDataSource/Orders.sbapp
. -
Save the table with Ctrl+S (Command+S on the Mac).
-
-
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.
-
In the Package Explorer view, double-click the Orders.lvconf entry to re-open the LiveView Configuration File Editor.
-
Select the Data Sources tab at the bottom of the editor view.
-
Select the Application check box. This opens new fields on the right.
-
In the Application Reference field, use the drop-down control to select
OrdersDataSource
. -
In the Output Stream field, type the name of the output stream in Orders.sbapp, which is
DataOut
. -
Save the table with Ctrl+S (Command+S on the Mac).
-
This step is to make sure the data source EventFlow module receives the correct data from its feed simulation.
-
Run the application. Right-click in the editor canvas or on the
orders.sbapp
file in the Package Explorer view and select → . -
Observe the Application Output tab. Look for the outgoing data stream to be automatically populated by the associated feed simulation.
-
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.
-
When done, press F9 or click the red Stop StreamBase Application button in Studio's top-level toolbar.
Now we are ready to compile and run the LiveView project on an instance of LiveView Server.
-
Select
my-first-liveview-project
in the Package Explorer view. -
Right-click and select
→ . 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. -
When you see the message
All tables have been loaded
in the Console view, you are ready to start LiveView Desktop.
Run the LiveView Desktop client to connect to the locally-running LiveView Server, and to query and view the results.
-
Start LiveView Desktop with one of the following methods:
-
On Windows, invoke
→ → → → . -
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.
-
-
In the dialog:
-
Type any username and no password.
-
In the Server field, enter
localhost
. -
Specify a Local workspace with any name.
-
Click
.
-
-
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.