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 called LIVEVIEW_URI that you can change so all the adapters point to a different LiveView server.

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 Package Explorer view, select the name of the project, right-click, and from the context menu, select Run AsLiveView Project. 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 Package 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.

Running This Sample in Terminal Windows

This section describes how to run the sample in UNIX terminal windows or Windows command prompt windows. On Windows, be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not the default command prompt.

  1. Open three terminal windows on UNIX, or three StreamBase Command Prompts on Windows.

  2. In window 1, navigate to the directory above where the HelloLiveView sample is installed, or to the directory above your workspace copy of the Hello LiveView sample.

  3. In windows 2 and 3, navigate to the directory where the sample_adapter_embedded_lv-sbd is installed, or to your workspace copy sample.

  4. In window 1, type:

    lv-server run sample_lv-helloliveview

    Wait until the console message "All tables have been loaded. LiveView is ready to accept client connections," appears before proceeding to the next step.

  5. In window 2, type:

    sbd -p 10001 -f sbd.sbconf lv2sbd.sbapp

    This window will display the tuples dequeued from the downstream application.

  6. In window 3, type:

    sbc -p 10001 dequeue

    The window shows the results from all the output streams. To see a single output stream, type:

    sbc -p 10001 dequeue StreamName
  7. Open another StreamBase Command Prompt. In this fourth window, type the following command to terminate LiveView Server.

    lv-client shutdown
  8. In window 4, type the following command to terminate StreamBase Server.

    sbadmin -p 10001 shutdown

     

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.

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.

In the default TIBCO StreamBase installation, this sample's files are initially installed in:

streambase-install-dir/sample/lv-sbd

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