Contents
Note
This document describes the sample for the legacy version of the ActiveSpaces operator, which is deprecated. For the description of the sample dedicated to the current ActiveSpaces operators, refer to see TIBCO ActiveSpaces Operator Sample.
This topic describes how to run the sample application for the TIBCO ActiveSpaces® legacy operator, and illustrates how to use the operator with an ActiveSpaces Metaspace. For more information on this operator, see Using the TIBCO ActiveSpaces Legacy Operator.
This sample includes an ActiveSpaces operator which by default connects 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
.
This sample has the following files:
-
The sample EventFlow application,
activespaces-legacy-operator.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 sample also contains an EventFlow application to illustrate the new ActiveSpaces operators,
activespaces.sbapp
.
The Studio project for this sample contains files for the current and legacy versions of the ActiveSpaces operators.
The steps to run this sample in Studio are as follows:
-
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 . On the Libraries tab of the dialog box that appears, if there is no entry for
as-common.jar
in the list, click the button. This will bring up file browser; navigate to your ActiveSpaces install's lib directory, selectas-common.jar
and click . Back in the Libraries tab, an entry will have been added foras-common.jar
. -
Expand the
as-common.jar
node, select Native Library Location and click the button. Enter the correct location of the ActiveSpaceslib
subdirectory and click , then click to dismiss the properties dialog. -
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
directory:$AS_HOME
/libjava -jar as-admin.jar -i
<path_to_sample_project>
/asAdminCLIScript.txt -
In the Package Explorer, double-click to open the
activespaces-legacy-operator.sbapp
application. -
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.
-
In the Manual Input view, select the
Commands
input stream. -
Enter the following values:
-
command
ID:ID1
-
command
:Put
-
activeSpacesTuple.employeeNumber
:1000
-
activeSpacesTuple.firstName
:Jane
-
activeSpacesTuple.lastName
:Doe
-
department
:Engineering
-
location
:Waltham MA
Click
, and observe that theResults
output stream received a tuple with a matchingcommandID
value and anevent
value ofPut
. If an employee withemployeeNumber
1000
already existed in the Space, the original value for that entry is also returned in theactiveSpaceTuple
field. -
-
Still in the Manual Input view, click the button then enter the following values:
-
command
ID:ID2
-
command
:Get
-
activeSpacesTuple.employeeNumber
:1000
Click
, and observe that theResults
output stream received a tuple with a matchingcommandID
value and anevent
value ofGet
. TheactiveSpaceTuple
field contains the current value of the requested tuple. -
-
When done, press F9 or click the
Stop Running Application button.
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.
-
Open three terminal windows on UNIX, or three StreamBase Command Prompts on Windows.
-
In window 1, navigate to the directory location where your project resides, then start StreamBase Server with the
.sbapp
file as its argument. For example:cd /d "C:\Users\
username
\Documents\StreamBase Studion.m
Workspace\sample_activespaces sbd -f sbd.sbconf activespaces-legacy-operator.sbapp -
In window 2, type:
sbc dequeue
This window will display tuples dequeued from the application's output ports.
-
In window 3, type:
sbc enq Commands
This window is now ready to accept tuples typed with CSV syntax.
-
In window 3, type:
ID1,Put,null,null,null,null,null,null,null,null,null,null,"1000,Jane,Doe,Engineering,Waltham MA"
-
Observe in window 2 one tuple is emitted on the
Results
stream with a matchingcommandID
value and anevent
value ofPut
:Results,ID1,Put,null,null
Or, if the Space already contained an entry for employee 1000 (say, for a John Smith), the result tuple will also contain the original value of that entry in its
activeSpacesTuple
field instead of anull
:Results,ID1,Put,null,"1000,John,Smith,Engineering,Waltham MA"
-
In window 3, type:
ID2,Get,null,null,null,null,null,null,null,null,null,null,"1000,null,null,null,null"
-
Observe in window 2: one tuple is emitted on the
Results
stream:Results,ID2,Get,null,"1000,Jane,Doe,Engineering,Waltham MA"
-
In window 2, type Ctrl+C to terminate the dequeuing process. Then type the following command to shut down the server:
sbadmin shutdown
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
→ . -
Type
active
to narrow the list of options. -
Select
ActiveSpaces Operator
from the Extending StreamBase category. -
Click OK.
StreamBase Studio creates a project for the ActiveSpaces Operator sample in your current Studio workspace.
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 default location of studio-workspace
on your system.