Contents
This sample uses a Merge operator to interlace trades from a Reuters and the Interactive Data PlusFeed (formerly Comstock),
based on trade time. The input streams contain the fields Symbol
, Volume
, PricePS
(per share), Time
, and FeedID
.
-
In the Package Explorer, double-click to open the
Merge.sbapp
application. Make sure the application is the currently active tab in the EventFlow Editor. -
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Application Output view, select the
MergeOut
output stream. No output is displayed at this point, but the dequeuer is prepared to receive output. This view eventually shows the output of the application. -
In the Manual Input view, select the
ComstockIn
input stream -
Enter
amat
,100
,23
,10
, and0
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click
, and observe that no output is displayed yet in the Application Output view. -
Enter
amat
,23
,10
, and1
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe that no output is displayed yet in the Application Output view.
-
Select the
ReutersIn
input stream. -
Enter
intc
,200
,21
,11
, and0
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe this data appears in the Application Output view:
Symbol=amat, Volume=100, PricePS=23.0, Time=10, FeedID=0
-
Enter
intc
,200
,21
,11
, and1
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe this data appears in the Application Output view.
Symbol=amat, Volume=100, PricePS=23.0, Time=10, FeedID=1
-
Enter
msft
,100
,40
,12
, and0
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe that no further output is displayed yet in the Application Output view.
-
Enter
msft
,100
,40
,12
, and1
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe that no further output is displayed yet in the Application Output view.
-
Select the ComstockIn input stream.
-
Enter
amat
,300
,24
,15
, and0
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe this data appears in the Application Output view.
Symbol=intc, Volume=200, PricePS=21.0, Time=11, FeedID=0 Symbol=msft, Volume=100, PricePS=40.0, Time=12, FeedID=0
-
Enter
amat
,300
,24
,15
, and1
in the Symbol, Volume, PricePS, Time, and FeedID fields, respectively.Click Send Data, and observe this data appears in the Application Output view.
Symbol=intc, Volume=200, PricePS=21.0, Time=11, FeedID=1 Symbol=msft, Volume=100, PricePS=40.0, Time=12, FeedID=1
-
When done, press F9 or click the Stop Running Application button.
This section describes how to run the sample in UNIX terminal windows or Windows command prompt windows. On 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 each window, navigate to the directory where the sample is installed, or to your workspace copy of the sample, as described above.
-
In window 1, type:
sbd Merge.sbapp
The window shows
notice[StreamBaseServer] listening on port 10000
. -
In window 2, type:
sbc dequeue MergeOut
No output is displayed at this point, but the dequeuer is prepared to receive output. This window eventually shows the output of the application.
-
In window 3, type:
sbc enqueue
The sbc command is now waiting for keyboard input. Type:
ComstockIn,amat,100,23,10,0
No output is displayed yet in the dequeue window.
-
Type:
ComstockIn,amat,100,23,10,1
.No output is displayed yet in the dequeue window.
-
Type:
ReutersIn,intc,200,21,11,0
.Observe this line in the dequeue window:
amat,100,23.000000,10,0.
-
Type:
ReutersIn,intc,200,21,11,1
.Observe this line in the dequeue window:
amat,100,23.000000,10,1.
-
Type:
ReutersIn,msft,100,40,12,0
.No further output is displayed yet in the dequeue window.
-
Type:
ReutersIn,msft,100,40,12,1
.No further output is displayed yet in the dequeue window.
-
Type:
ComstockIn,amat,300,24,15,0
.Observe these lines in the dequeue window:
intc,200,21.000000,11,0 msft,100,40.000000,12,0
-
Type:
ComstockIn,amat,300,24,15,1
.Observe these lines in the dequeue window:
intc,200,21.000000,11,1 msft,100,40.000000,12,1
-
In window 2, type: Ctrl+Z (Windows) or Ctrl+D (UNIX) to exit the sbc session.
-
In window 3, type the following command to terminate the server and dequeuer:
sbadmin shutdown
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, click
→ . -
Select operator from the Data Constructs and Operators category.
-
Click OK.
StreamBase Studio creates a single project for the operator samples.
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_operator
See Default Installation Directories for the default 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/operator
See Default Installation Directories for the default location of studio-workspace
on your system.