MarketFactory Adapters Sample

This sample demonstrates the use of the TIBCO StreamBase® Adapters for MarketFactory™.

Importing This Sample into StreamBase Studio

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

  • From the top menu, click FileLoad StreamBase Sample.

  • Select this sample from the Embedded Input Adapters list.

  • Click OK.

StreamBase Studio creates a project for this sample.

Sample Location

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 Studio n.m Workspace\
      sample_adapter_embedded_marketfactory

Running This Sample in StreamBase Studio

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.

Running the Enhanced Market Data sample in StreamBase Studio

  1. In the Package Explorer view, double-click MarketFactoryMarketDataSample.sbapp.

  2. Select the adapter icon to open the Properties view for the adapter.

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

  4. Save the application.

  5. Click the Run button. This opens the SB Test/Debug perspective and starts the application.

  6. 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 and MDSymbolMapEvents streams indicating that the adapter has established a connection to the server.

  7. In the Manual Input view, select the AdapterCommands stream. Enter disconnect in the command field. Click Send Data and observe that a tuple has been emitted on the MDEvents stream, and a message has been printed to the console to indicate the adapter has disconnected from the MarketFactory server.

  8. In the Manual Input view, select the AdapterCommands stream again and enter connect in the command field. Click Send Data and observe that new tuples have been emitted on the MDEvents and MDSymbolMapEvents streams indicating that the adapter has re-established the connection to the server.

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

Running the Trading sample in StreamBase Studio

  1. In the Package Explorer view, double-click MarketFactoryTradingSample.sbapp.

  2. Select the Input adapter icon to open the Properties view for the adapter.

  3. Select the Adapter Properties tab and enter the Host Name and Port Number of the MarketFactory Trading server to which you have access.

  4. Enter the User Name and Password used to sign on to the Trading server.

  5. Save the application.

  6. Click the Run button. This opens the SB Test/Debug perspective and starts the application.

  7. 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 and TSymbolMapEvents streams indicating that the adapter has established a connection to the server.

  8. In the Manual Input view, select the AdapterCommands stream. Enter disconnect in the command field. Click Send Data and observe that a a tuple has been emitted on the TEvents stream, and a message has been printed to the console to indicate the adapter has disconnected from the MarketFactory server.

  9. In the Manual Input view, select the AdapterCommands stream again and enter connect in the command field. Click Send Data and observe that new tuples have been emitted on the TEvents and TSymbolMapEvents streams indicating that the adapter has re-established the connection to the server.

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

Running This Sample in Terminal Windows

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.

Running the Enhanced Market Data Sample in Terminal Windows

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

  2. In window 1, type:

    sbd MarketFactoryMarketDataSample.sbapp

  3. In window 2, type:

    sbc dequeue -v

    This window displays the tuples dequeued from the adapter's output port.

  4. In window 3, disconnect from the MarketFactory server:

    echo disconnect | sbc enqueue MDCommands

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

  6. In window 3, reconnect to the MarketFactory server:

    echo connect | sbc enqueue MDCommands

  7. Observe in window 2 that Tuples are again emitted from the MDEvents and MDSymbolMapEvents streams. A message is issued in window 1 to indicate the adapter has reconnected to the MarketFactory server.

  8. In window 3, type the following command to terminate the server and dequeuer:

    sbadmin shutdown

Running the Trading Sample in Terminal Windows

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

  2. In window 1, type:

    sbd MarketFactoryTradingSample.sbapp

  3. In window 2, type:

    sbc dequeue -v

    This window displays the tuples dequeued from the adapter's output port.

  4. In window 3, disconnect from the MarketFactory server:

    echo disconnect | sbc enqueue TCommands

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

  6. In window 3, reconnect to the MarketFactory server:

    echo connect | sbc enqueue TCommands

  7. Observe in window 2 that Tuples are again emitted from the TEvents and TSymbolMapEvents streams. A message is issued in window 1 to indicate the adapter has reconnected to the MarketFactory server.

  8. In window 3, type the following command to terminate the server and dequeuer:

    sbadmin shutdown