TIBCO ActiveSpaces Operator Sample

About This Sample

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.

For more information on this operator, see Using the TIBCO ActiveSpaces Operators.

Importing This Sample into StreamBase Studio

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

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

  • Type active to narrow the list of options.

  • Select TIBCO ActiveSpaces Operators from the Other TIBCO Product Connectivity category.

  • Click OK.

StreamBase Studio creates a single project for the ActiveSpaces Operator samples.

Running This Sample in StreamBase Studio

  1. Before running you must configure the project to locate and load the ActiveSpaces libraries. In the Project 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. By default, the sample is configured to run both the StreamBase application and the second ActiveSpaces node locally (using the loopback 127.0.0.1 IP address). If you wish to run the nodes on separate machines you will have to edit asAdminCLIScript.txt and sbd.sbconf to reflect the actual IP addresses involved.

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

  5. In the Project Explorer, open the sample you just loaded.

  6. Open the src/main/eventflow folder.

  7. Open the package folder (most samples contain a single package folder. Open the top-level package folder if your sample contains more than one folder).

  8. Open the activespaces.sbapp application and click the Run button. This opens the SB Test/Debug perspective and starts the application.

    If you see red marks, wait a moment for the project in Studio to load its features.

    If red marks do not resolve themselves in a moment, select the project and right-click MavenUpdate Project from the context menu.

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

  10. Enter the following values:

    • passthrough.id: ID1

    Click Send Data (which triggers the tuple to be sent to an ActiveSpaces Begin Transaction Operator and initiates a transaction 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.

  11. Still in the Manual Input view, select the InBrowse stream and click Send Data (leaving all fields null). This causes 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.

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

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

This Sample's Files

This sample has the following files:

activespaces.sbapp

Sample EventFlow application.

sbd.sbconf

Used by the StreamBase Server to correctly configure the Java environment to locate the ActiveSpaces libraries.

asAdminCLIScript.txt

A text file that 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.

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_activespaces

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