- Index

< Previous |  | Next >

# 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 data grid. For more information on this operator, see Using the TIBCO ActiveSpaces Operators.

## Sample Overview

This sample includes a number of ActiveSpaces operators, which by default connect to an ActiveSpaces data grid named `TestGrid` on localhost. The sample data grid supplied with the ActiveSpaces installation is assumed to be running on localhost already, by executing `%TIBDG_ROOT%/samples/scripts/as-start.bat` on Windows systems or the corresponding script on other platforms.

Once connected, you can use the sample to put rows into and retrieve rows from the sample table (named `t1`) 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 File → Load StreamBase Sample.

- Enter `act` to narrow the list of options.

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

- Click OK.

## Running This Sample in StreamBase Studio

1. Before running you must configure the project to locate and load the ActiveSpaces libraries. Open `src\main\configurations\engine.conf` and adjust paths based on your own install locations for TIBCO ActiveSpaces and TIBCO FTL.

2. Make sure the data grid that ships as an ActiveSpaces sample is up and running on the local machine (or, if running it on another machine, edit `adapter-configurations.xml` to point the data grid definition to the right IP address). You can launch the data grid by running `%TIBDG_ROOT%/sample/scripts/as-start.bat`.

3. In the Project Explorer view, open the sample you just loaded.

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

   If the red marks do not resolve themselves after a minute, select the project, right-click, and select Maven → Update Project from the context menu.

4. Open the `src/main/eventflow/`packageName`` folder.

5. Open the `activespaces.sbapp` file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

6. Once the application has started, the ActiveSpaces Control operator connects to the data grid then sends a `Connected` tuple to the application.

7. In the Manual Input view, select the `PutCmd` input stream.

8. Enter the following values:

   - key: `1`

   - value: `One`

   Click Send Data and observe that the `PutResults` output stream received a tuple with its `input` field set to the given command tuple and its `row` field set to null, indicating that the operation succeeded and finished.

9. Still in the Manual Input view, select the `GetCmd` stream and enter `1` as the value for the key field, then click Send Data. This fetches the row with key `1` and emit it on the GetResults output stream, followed by a marker tuple (row = null) to indicate the operation finished executing.

10. You may similarly send arbitrary queries to a table (for example, `SELECT * FROM t1 WHERE key > 0`) using the QueryCmd stream and remove rows using the DeleteCmd stream. Of note is the ControlCmd stream which allows you to send control commands to, for example, disconnect from the data grid. Finally, if you have defined your data grid connection to be transacted (by adding `<setting name="transacted-session" val="true"/>` to the definition) you can commit or rollback your data grid operations using the `TxCmd` input stream.

11. When done, press F9 or click the Terminate EventFlow Fragment button.

## This Sample's Files

This sample has the following files:

activespaces.sbapp

  Sample EventFlow application.

engine.conf

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

adapter-configurations.xml

  Definitions for available ActiveSpaces data grids.

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