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 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 list.

  • Click OK.

StreamBase Studio creates a single project containing the sample files.

Running This Sample in StreamBase Studio

  1. First, load and run the Hello LiveView sample as delivered with LiveView.

    1. Start StreamBase Studio in the SB Authoring perspective.

    2. Load the Hello LiveView sample.

      1. Select FileLoad StreamBase Sample from Studio's top-level menu.

      2. In the search field, enter Hello to narrow the list of samples.

      3. Select the Hello LiveView sample from the TIBCO Live Datamart list.

      4. Click OK.

      The Hello LiveView sample loads into Studio with the project name sample_lv-helloliveview.

    3. In the Project Explorer view, select the name of the project, right-click, and from the context menu, select Run AsLiveView Fragment. The Console view shows several messages as the LiveView Server compiles the project and starts. Wait until the console message All tables have been loaded. LiveView is ready to accept client connections before proceeding to the next step.

  2. In the Project Explorer view, navigate back the to the sample_adapter_embedded_lv-sbd folder and double-click to open the lv2sbd.sbapp application. Make sure the application is the currently active tab in the EventFlow Editor.

  3. Click the Run button. This opens the SB Test/Debug perspective and starts the application.

  4. In the Application Output view, observe the tuples output by the 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.

  5. 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 all the individual fields mean on these input streams.

  6. When done, press F9 or click the Stop Running Application 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.

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 location of studio-workspace on your system.