Instead of creating a new application module, you can also extract a subset of components from an existing EventFlow application. StreamBase creates the new application module for you, and inserts a module reference in the EventFlow application that references the new application module.
The graphical procedure described in this topic is only available for EventFlow applications. StreamBase Studio does not provide a method to extract an application module from a StreamSQL application.
-
In the StreamBase Studio SB Authoring perspective, open the application that contains the components you want to extract.
-
In the EventFlow Editor, select a contiguous group of components to include in the application module. In the following example, the selected group includes two Map operators and a Gather operator:
Observe the following rules for selecting components:
-
Application modules do not include the streams going into and out of the group of components you select, and by default, such streams are omitted from your selection. For example, in the preceding screen, the selection includes the internal arcs from the two Map operators to the Gather operator, but omits the arcs going into the two Map operators and out of
GatherAlarms. As we will show later, StreamBase uses an internal representation of input and output streams for the selected components when it creates the module.If you explicitly add any of these streams or arcs to your selection, the Extract as Module command is not available.
-
Do not omit any components that a selected operator or data construct depends on. For example, if you select a Query operator but omit its associated Query Table data construct, you cannot extract your selection into a module.
-
If one or more components that you select for extraction already have their concurrency multiplicity option enabled, those settings are preserved in the new module's EventFlow settings. However, multiplicity concurrency for components inside a module is probably no longer appropriate. (See Execution Order and Concurrency for further information.) In the most likely scenario, take the following steps:
-
Disable the concurrency options for each individual operator inside the module.
-
Instead, enable the concurrency option for the module reference itself.
-
-
-
Select from the Diagram menu, or right-click your selection and choose the same command from the context menu.
-
In the Extract as Module dialog:
-
Specify a name for the new module.
-
Choose whether to open the module in the editor.
-
-
Click . StreamBase creates a new EventFlow application file with the module name you entered, containing the components you selected. The new application is created in the project folder of the application you extracted it from. At the same time, an icon for the new application is added in the Modules drawer of the Palette view.
In your current EventFlow application, the selected components are replaced with a single new Module Reference component, which links to the new application module.
Notice the input and output ports on the new Module Reference icon, which StreamBase has connected to appropriate components in your application.
Open the new application module by selecting the Module Reference and pressing F3, or by right-clicking the Module Reference and selecting from the context menu. The following example shows the EventFlow canvas of the application module created in the preceding steps. Compare it to the first figure in this topic, which shows the initial selection of elements. Notice that where the selection omitted the outer arcs, StreamBase has added input and output streams. These streams have the same schemas as the corresponding connections in the application:
-
Verify that the new module reference has no typecheck errors. If it does, you may need to edit the module reference's properties, as described in Using Module References.
Note that changing module reference properties does not change the application module being referenced: it is a local change that affects only the referencing application. By contrast, if you change an application module, the changes affect every application that references it.
-
Save your application.
