LiveView Adapters Sample

This sample uses the LiveView adapters to query, publish, delete, and create tables on a running LDM server from an Event flow application. This sample assumes you are running the Hello World LDM sample on localhost. There is a module parameter called LIVEVIEW_URI that you can change so all the adapters point to a different LDM 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 Load StreamBase Projects dialog, open the TIBCO Live Datamart category.

      3. Select the sample whose description is Shows a simple Hello World application and press 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, navigate back the to the sample_adapter_embedded_lv-sbd folder and double-click to open the sample_adapter_embedded_lv-sbd/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/drop tables on the configured LDM 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.

  • Select this 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 the permission problems that can occur when trying to work with the initially installed location of the sample. 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.

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 location of streambase-install-dir on your system. This location may require administrator privileges for write access, depending on your platform.