Shared Tables Across Containers Sample

The Shared Tables Across Containers sample application demonstrates how to use the same StreamBase Query Tables from different modules in different containers.

This sample includes three equal-value EventFlow modules; that is, none of the three is a top-level module that references the other two. Instead, the module TableHome.sbapp contains a Query Table, while Writer.sbapp writes to that table, and Reader.sbapp reads from that table. All three modules reside in their own containers so that table access is always across container boundaries.

This Sample's Files

The Shared Tables Across Containers sample includes the following files:

File Purpose
cross-table.sbdeploy A StreamBase deployment file that specifies loading each EventFlow module into its own named container. Use this file to run this sample from StreamBase Studio and from the command line.
TableHome.sbapp An EventFlow module consisting of a single element, a shared Query Table. The sbdeploy file specifies running this module in the container named default.
Writer.sbapp An EventFlow module that performs writes to the shared Query Table defined in TableHome.sbapp. This module includes a Query Table with a Data Location setting of Defined by connection path. This module runs in a container named writer.
Reader.sbapp An EventFlow module that performs reads on the shared Query Table defined in TableHome.sbapp. This module also includes a Query Table with a Data Location setting as above. This runs in a container named reader.
fswrite.sbfs A StreamBase feed simulation file that is used by the embedded feed simulation adapter in the Writer.sbapp module. The feed simulation generates a stream of transaction entries for products with one of seven product codes (SKUs) across four possible store locations.
fsread.sbfs A StreamBase feed simulation file that is used by the embedded feed simulation adapter in the Reader.sbapp module. The feed simulation generates a stream of random reads of the Query Table using one of the seven valid SKU product codes. This returns the last-entered transaction report for the product code entered.

This Sample's Launch Configuration

The Shared Tables Across Containers sample's launch configuration includes the following application module to container mappings:

Application Module Container
TableHome.sbapp default
Reader.sbapp reader
Writer.sbapp writer

Running This Sample in StreamBase Studio

  1. In the Package Explorer, open the sample_cross-containers-table project folder.

  2. Right-click cross-containers-table.launch and in the context menu select Run As and then select cross-containers-table.

    This opens the StreamBase Test/Debug perspective and starts the sample.

  3. Observe transaction data like the following in the Application Output view streaming at a rate of one entry per second.

    Time Output Stream Fields
    17:08:57 reader.OutputStream sku=EFGH, category=toys, color=green, quantityRemaining=11, lastSoldPrice=1.00
    17:08:58 reader.OutputStream sku=WXYZ, category=electronics, color=red, quantityRemaining=60, lastSoldPrice=12.99
  4. Notice that there are no entries for the writer.out:FeedSimulation_1 stream except at start up time. The writes performed by the writer are not logged to an output stream, but you can see evidence that they are happening by observing the changing data output by the reader.OutputStream stream.

  5. [Optional] You can choose to manually enter an sku to reader.sbapp in the Manual Input view.

    1. In the Manual Input view enter one of the following in the sku field: ABCD, EFGH, LMNO, QRST, or WXYZ.

    2. Click Send Data, and observe that there is an entry in the Application Output view for the sku you entered.

  6. When done, press F9 or click the Stop Running Application button.

Running This Sample at the Command Prompt

Importing This Sample into StreamBase Studio

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

  • From the top menu, select FileLoad StreamBase Sample.

  • Select Tables Across Containers from the Applications category.

  • Click OK.

StreamBase Studio creates a single project for all the operator samples.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample's files to a project folder in your Studio workspace directory. Because the Studio workspace location is normally part of your home directory, you have full access rights there by default.

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/cross-container-table

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/cross-container-table

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.