Contents
This sample demonstrates the use of the TIBCO StreamBase® Adapters for MarketFactory™.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, click
→ . -
Select this sample from the Embedded Input Adapters list.
-
Click OK.
StreamBase Studio creates a project for this sample.
By default, the sample files are installed in:
-
On Windows:
C:\TIBCO\sb-cep\
n.m
\sample\adapter\embedded\marketfactory -
On UNIX:
/opt/tibco/sb-cep/
n.m
/sample/adapter/embedded/marketfactory -
On Mac:
/Applications/tibco StreamBase/
n.m.x
/sample/adapter/embedded/marketfactory
When you load the sample into StreamBase Studio, Studio copies the sample project's
files to your Studio workspace. TIBCO recommends that you use the workspace copy of
the sample, especially on UNIX, where you may not have write access to /opt/tibco/sb-cep
. In the default installation, the path to this
sample in your Studio workspace is:
UNIX and Mac: $HOME/Documents/streambase-studio-n.m
-workspace/ sample_adapter_embedded_marketfactory Windows: C:\Users\username
\Documents\StreamBase Studion.m
Workspace\ sample_adapter_embedded_marketfactory
Note
To use this sample, you must have access to a valid MarketFactory Enhanced Market Data and Trading server.
This sample contains two separate applications: one demonstrates the use of the Enhanced Market Data input adapter and the other demonstrates the use of the Trading input and output adapters.
-
In the Package Explorer view, double-click
MarketFactoryMarketDataSample.sbapp
. -
Select the adapter icon to open the Properties view for the adapter.
-
Select the Adapter Properties tab and enter the Host Name and Port Number of the MarketFactory Enhanced Market Data server to which you have access.
-
Save the application.
-
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Test/Debug Perspective, open the Application Output view. If connectivity to your MarketFactory server is configured correctly, look for tuples emitted on the
MDEvents
andMDSymbolMapEvents
streams indicating that the adapter has established a connection to the server. -
In the Manual Input view, select the
AdapterCommands
stream. Enterdisconnect
in thecommand
field. Click and observe that a tuple has been emitted on theMDEvents
stream, and a message has been printed to the console to indicate the adapter has disconnected from the MarketFactory server. -
In the Manual Input view, select the
AdapterCommands
stream again and enterconnect
in thecommand
field. Click and observe that new tuples have been emitted on theMDEvents
andMDSymbolMapEvents
streams indicating that the adapter has re-established the connection to the server. -
When done, press F9 or click the Stop Running Application button.
-
In the Package Explorer view, double-click
MarketFactoryTradingSample.sbapp
. -
Select the Input adapter icon to open the Properties view for the adapter.
-
Select the Adapter Properties tab and enter the Host Name and Port Number of the MarketFactory Trading server to which you have access.
-
Enter the User Name and Password used to sign on to the Trading server.
-
Save the application.
-
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Test/Debug Perspective, open the Application Output view. If connectivity to your MarketFactory server is configured correctly, look for tuples emitted on the
TEvents
andTSymbolMapEvents
streams indicating that the adapter has established a connection to the server. -
In the Manual Input view, select the
AdapterCommands
stream. Enterdisconnect
in thecommand
field. Click and observe that a a tuple has been emitted on theTEvents
stream, and a message has been printed to the console to indicate the adapter has disconnected from the MarketFactory server. -
In the Manual Input view, select the
AdapterCommands
stream again and enterconnect
in thecommand
field. Click and observe that new tuples have been emitted on theTEvents
andTSymbolMapEvents
streams indicating that the adapter has re-established the connection to the server. -
When done, press F9 or click the Stop Running Application button.
This sample contains two separate applications: one demonstrates the use of the Enhanced Market Data input adapter and the other demonstrates the use of the Trading input and output adapters.
This section describes how to run the samples 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.
The steps described below assume that you have already correctly configured the
Host Name
and Port Number
for the Enhanced Market Data sample, and the Host Name
,
Port Number
, Username
and
Password
for the Trading adapter as described in the
previous section.
-
Open three terminal windows on UNIX, or three StreamBase Command Prompts on Windows. In each window, navigate to your workspace copy of the sample, as described above.
-
In window 1, type:
sbd MarketFactoryMarketDataSample.sbapp
-
In window 2, type:
sbc dequeue -v
This window displays the tuples dequeued from the adapter's output port.
-
In window 3, disconnect from the MarketFactory server:
echo disconnect | sbc enqueue MDCommands
-
Observe in window 2 that a Disconnect Tuple is emitted from the
MDEvents
port and a message is issued in window 1 to indicate the adapter has disconnected from the MarketFactory server. -
In window 3, reconnect to the MarketFactory server:
echo connect | sbc enqueue MDCommands
-
Observe in window 2 that Tuples are again emitted from the
MDEvents
andMDSymbolMapEvents
streams. A message is issued in window 1 to indicate the adapter has reconnected to the MarketFactory server. -
In window 3, type the following command to terminate the server and dequeuer:
sbadmin shutdown
-
Open three terminal windows on UNIX, or three StreamBase Command Prompts on Windows. In each window, navigate to your workspace copy of the sample, as described above.
-
In window 1, type:
sbd MarketFactoryTradingSample.sbapp
-
In window 2, type:
sbc dequeue -v
This window displays the tuples dequeued from the adapter's output port.
-
In window 3, disconnect from the MarketFactory server:
echo disconnect | sbc enqueue TCommands
-
Observe in window 2 that a Disconnect Tuple is emitted from the
TEvents
port and a message is issued in window 1 to indicate the adapter has disconnected from the MarketFactory server. -
In window 3, reconnect to the MarketFactory server:
echo connect | sbc enqueue TCommands
-
Observe in window 2 that Tuples are again emitted from the
TEvents
andTSymbolMapEvents
streams. A message is issued in window 1 to indicate the adapter has reconnected to the MarketFactory server. -
In window 3, type the following command to terminate the server and dequeuer:
sbadmin shutdown