Extension Point Operator Sample

About This Sample

This sample uses an Extension Point operator to dispatch tuples to one of two submodules, based on a user-specified action at runtime. The submodules simply double or triple an integer field within the incoming tuple. If no action is specified, the tuple is sent to both modules.

This sample illustrates StreamBase interfaces used with the Extension Point operator, and illustrates the dispatch of tuples to one of two modules based on an expression that evaluates to the identifier of one of the modules. This sample also illustrates the use of a PNG image file to provide the Extension Point operator with a custom icon.

This sample illustrates several aspects of Extension Point operators and StreamBase interfaces. For further exploration of StreamBase interfaces, see the Interfaces Sample.

Importing This Sample into StreamBase Studio

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

  • From the top-level menu, click File>Import Samples and Community Content.

  • Enter sample group to narrow the list of options.

  • Select Operator sample group from the Data Constructs and Operators category.

  • Click Import Now.

StreamBase Studio creates a single project for the operator samples.

Running This Sample in StreamBase Studio

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

  2. Open the src/main/eventflow/com.tibco.sb.sample.operator folder.

  3. Open the ExtensionPoint.sbapp file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

  4. In the Output Streams view, select the Output output stream. No output is displayed at this point.

  5. In the Manual Input view, select the Input input stream

  6. Enter the following field values:

    Field Enter this value
    value 2
    action double
  7. Click Send Data, and a tuple arrives in the Output Streams view. Select the new tuple and observe this data below the output stream table:

    value=2, action=double, newValue=4, path=[Entering port 1 for Name dispatch,Doubler.sbapp]
  8. In the Manual Input view, enter the following field values:

    Field Enter this value
    value 2
    action triple
  9. Click Send Data, and a tuple arrives in the Output Streams view. Select the new tuple and observe this data below the output stream table:

    value=2, action=triple, newValue=6, path=[Entering port 1 for Name dispatch,Tripler.sbapp]
  10. In the Manual Input view, enter the following field values:

    Field Enter this value
    value 3
    action null
  11. Click Send Data, and two tuples arrive in the Output Streams view. Select the new tuples and observe this data below the output stream table:

    value=3, action=null, newValue=6, path=[Entering port 2 for Broadcast dispatch,Doubler.sbapp]
    value=3, action=null, newValue=9, path=[Entering port 2 for Broadcast dispatch,Tripler.sbapp]
  12. When done, press F9 or click the Terminate EventFlow Fragment button.

This Sample's Files

The Extension Point sample is composed of following files:

ExtensionPoint.sbapp

The top-level application for this sample. Its input stream accepts an integer value and a string field, action, that determines what to do with the integer. The recognized values for action are double, triple, and null.

The following file is located in the same package folder as the sample operator's application files.

Multiplier.sbint

A StreamBase interface that defines two input streams and one output stream, and defines named schemas used by those streams.

The following files are located in the com.tibco.sb.sample.operator.modules package folder of the sample operator's src/main/eventflow/packageName project directory.

Doubler.sbapp

A module that implements the streams and schemas defined in the Multiplier.sbint interface. This module doubles its input value, and appends as a list(string) the StreamBase path through this module.

Tripler.sbapp

Another module that implements the Multiplier.sbint interface. This module performs the same actions as Doubler.sbapp except that it triples its input value.

Open ExtensionPoint.sbapp in Studio and look at the Properties view for the Extension Point operator named Multiply. The Concurrency tab is entirely responsible for directing input tuples to one or both of the referenced modules, either Doubler.sbapp or Tripler.sbapp:

  • If a tuple enters input port 2, the dispatch style is Broadcast, which means the tuple is sent to both modules.

  • If a tuple enters input port 1, the dispatch style is Name. In this case, the expression lower(action) must resolve to the identifier of one of the two modules (double or triple) as defined in the Modules tab.

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_operator

See Default Installation Directories for the default location of studio-workspace on your system.