LiveView Adapters Sample

Introduction

This sample uses the LiveView adapters to query, publish, delete, and create tables on a running LiveView server from an EventFlow application. This sample assumes you are running the Hello World LiveView sample on localhost. There is a module parameter named LIVEVIEW_URI that you can change so all the adapters point to a different LiveView server.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, click FileLoad StreamBase Sample.

  • In the search field, enter ready to narrow the list of samples.

  • Select the LiveView Adapters sample from the TIBCO Live Datamart category.

  • Click OK.

This sample also requires a copy of the Hello LiveView sample:

  • From the top-level menu, click FileLoad StreamBase Sample.

  • In the search field, enter hello to narrow the list of samples.

  • Select the Hello LiveView sample from the TIBCO Live Datamart category.

  • Click OK.

StreamBase Studio creates a separate project for each sample.

Running This Sample in StreamBase Studio

  1. First, run the Hello LiveView sample:

    • When this sample loads, it opens the LiveView Project Viewer, showing four icons. To start the sample, click the Run button in the upper right corner of the Project Viewer.

    • The Console view shows several messages as the LiveView Server compiles the project and starts. Wait for the console message All tables have been loaded before proceeding to the next step.

  2. In the Project Explorer view, navigate back to the sample_adapter_embedded_lv-sbd folder.

  3. Open the src/main/eventflow/packageName folder.

  4. Double-click to open the lv2sbd.sbapp module.

  5. Make sure the module is the currently active tab in the EventFlow Editor, then click the Run button in Studio's top-level menu. This opens the SB Test/Debug perspective and starts the module.

  6. In the Output Streams view, observe tuples emitted by various streams.

    • The ReadyStatus, QueryStatus, PublishStatus, DeleteStatus, and CreateDropStatus streams all show the LiveView Server status as CONNECTED.

    • The QueryStatus stream shows the status of the two preconfigured queries:

      select * from ItemsSales where category=='book'
      select avg(LastSoldPrice) as AvgSoldPrice, category from ItemsSales where true group by category
    • The QueryOut stream shows the output from the first query.

    • The AggQueryOut stream show the output from the second query.

  7. Using the QueryIn, PublishIn, DeleteIn, CreateDropIn streams you can register additional queries, publish data, delete data, or create or drop tables on the configured LiveView server. See the individual adapter documentation for what the individual fields mean on these input streams.

  8. When done, press F9 or click the Terminate EventFlow Fragment button to stop the EventFlow application and click the the red square Terminate button in the Console View's toolbar to stop the LiveView Server sessions.

  9. When done, press F9 or click the Terminate EventFlow Fragment button to stop the EventFlow module.

  10. Click the Terminate LiveView Fragment button to stop the Hello LiveView server.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/sample_lv-sbd

See Default Installation Directories for the default location of studio-workspace on your system.