TIBCO ActiveSpaces Operator Sample

This topic describes how to run the TIBCO ActiveSpaces® operator sample application, which illustrates how to use the operators with an ActivesSpaces Metaspace. For more information on this operator, see Using the TIBCO ActiveSpaces Operators.

There is a separate sample to show how to use the deprecated see Legacy TIBCO ActiveSpaces operator. If you are developing a new project, use the operators described in thie sample.

Sample Overview

This sample includes a number of ActiveSpaces operators, which by default connect to an ActiveSpaces Metaspace named sbms, which is assumed to already be running, and a Space called sbspace. Once connected, you can use the sample to send and receive tuples from sbspace using the various ActiveSpaces Operators.

This Sample's Files

This sample has the following files:

  • The sample EventFlow application, activespaces.sbapp.

  • A corresponding sbd.sbconf, which is used by the StreamBase Server to correctly configure the Java environment to locate the ActiveSpaces libraries.

  • A text file named asAdminCLIScript.txt which can be used as an input to the ActiveSpaces Admin CommandLine Interface utility to create the required Metaspace as well as a Space with the required schema.

  • The sam1ple also contains an EventFlow application to illustrate the legacy ActiveSpaces operator, activespaceslegacy.sbapp.

The Studio project for this sample contains files for the current and legacy versions of the ActiveSpaces operators.

Running This Sample in StreamBase Studio

The steps to run this sample in Studio are as follows:

  1. Before running you must configure the project to locate and load the ActiveSpaces libraries. In the Package Explorer, right-click on the top-level node of your project and select Build Path | Configure Build Path. On the Libraries tab of the dialog box that appears, if there is no entry for as-common.jar in the list, click the Add External JARs button. This will bring up file browser; navigate to your ActiveSpaces install's lib directory, select as-common.jar and click OK. Back in the Libraries tab, an entry will have been added for as-common.jar.

  2. Expand the as-common.jar node, select Native Library Location and click the Edit button. Enter the correct location of the ActiveSpaces lib subdirectory and click OK, then click OK to dismiss the properties dialog.

  3. Make sure there is a Metaspace and Space currently up and running on the machine to which you wish to connect. The sample includes a configuration file called asAdminCLIScript.txt which can be used to start such a Metaspace and correctly-defined Space on your machine using the following command, run from the $AS_HOME/lib directory:

    java -jar as-admin.jar -i <path_to_sample_project>/asAdminCLIScript.txt

  4. In the Package Explorer, double-click to open the activespaces.sbapp application.

  5. Make sure the application is the currently active tab in the EventFlow editor, then click the Run button. This opens the SB Test/Debug perspective and starts the application.

  6. In the Manual Input view, select the InBeginTx input stream.

  7. Enter the following values:

    • passthrough.id: ID1

    Click Send Data (which will trigger the tuple to be sent to an ActiveSpaces Begin Transaction Operator and cause a transaction to be initiated during which two tuples are sent to the Space as a single transaction), and observe that the OutCommitTx output stream received a tuple with a matching ID value, indicated that the transaction has been committed to the space.

  8. Still in the Manual Input view, select the InBrowse stream and click Send Data (leaving all fields null). This will cause the Space to list all its tuples (the asTuple field contains the current value of each requested tuple) on the OutBrowse stream, terminating the list with a punctuation tuple with its asTuple field set to null.

  9. You may similarly add tuples to the Space using the InPut stream, remove tuples using the InTake stream, etc. Of note is the InControl stream which allows you to send control commands to, for example, disconnect from the Metaspace.

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

Running This Sample in Terminal Windows

This section describes how to run this sample in Windows command prompt or Unix terminal 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. Edit sbd.sbconf in the sample's directory to update the <jar> and <library> entries to reflect the correct location of your ActiveSpaces as-common.jar file and lib subdirectory. As shipped, the sbd.sbconf file specifies those paths using the ${AS_HOME} environment variable, since ActiveSpaces recommends using this variable to specify the root location of its product. If this environment variable is correctly set, the sample should work without the need to change the paths. Otherwise, you must edit sbd.sbconf as described above.

  2. Make sure there is a Metaspace and Space currently up and running on the machine to which you wish to connect. The sample includes a configuration file called asAdminCLIScript.txt which can be used to start such a Metaspace and correctly-defined Space on your machine using the following command, run from the $AS_HOME/lib directory:

    java -jar as-admin.jar -i <path_to_sample_project>/asAdminCLIScript.txt

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

  4. In window 1, navigate to the directory location where your project resides, then start StreamBase Server with the application file as its argument. For example:

    cd /d "C:\Users\username\Documents\StreamBase Studio X.Y Workspace\sample_activespaces"
    sbd -f sbd.sbconf activespaces.sbapp
    
  5. In window 2, type:

    sbc dequeue

    This window will display tuples dequeued from the application's output ports.

  6. In window 3, type:

    sbc enq InBeginTx

    This window is now ready to accept tuples to the InBeginTx stream, typed with CSV syntax.

  7. In window 3, type the following (which will trigger a tuple to be sent to an ActiveSpaces Transaction Begin Operator and cause a transaction to be initiated during which two tuples are sent to the Space as a single transaction):

    "ID1"

  8. Observe in window 2 one tuple is emitted on the OutCommitTx stream with a passthrough.id value matching that of the input tuple sent in the previous step, indicating that the transaction was committed:

    OutCommitTx,ID1

  9. In window 3, type Ctrl+C to exit sbc, then type:

    sbc enq InBrowse

    This window is now ready to accept tuples to the InBrowse stream, typed with CSV syntax.

  10. In window 3, type:

    null,null

  11. This will cause the Space to list all its tuples (the asTuple field contains the current value of each requested tuple) on the OutBrowse stream, terminating the list with a punctuation tuple with its asTuple field set to null. You can observe these tuples in window 2:

    OutBrowse,"1001,John,Doe,Marketing,""Waltham, MA"""

    OutBrowse,"1000,Jane,Doe,Engineering,""Waltham, MA"""

    OutBrowse,null

  12. In window 2, type Ctrl+C to terminate the dequeuing process. Then type the following command to shut down the server:

    sbadmin shutdown

Importing This Sample into StreamBase Studio

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

  • From the top-leve menu, select FileLoad StreamBase Sample.

  • Type active to narrow the list of options.

  • Select TIBCO ActiveSpaces Operators from the Extending StreamBase category.

  • Click OK.

StreamBase Studio creates a single project for the ActiveSpaces Operator samples in your current Studio workspace.

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_activespaces

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/activespaces

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.