Contents
StreamBase deployment files are a type of configuration file that specify the names of containers and application modules to be run, plus runtime setup options such as container connections, module parameter definitions, and trace file configuration. See StreamBase Deployment Files for an overview, and see StreamBase Deployment File XML Reference for the XML syntax of deployment files.
This sample illustrates the use of deployment files to run the same multi-container EventFlow application in two different ways without editing EventFlow and without using separate server configuration files.
Note
Do not run this sample's EventFlow file, Main.sbapp
. Instead, run one of this sample's StreamBase deployment files, as described in the steps below.
StreamBase deployment files can also be used to specify externally defined modules that implement the interface defined in an Extension Point operator. That feature of deployment files is illustrated in a separate sample in the Operator Sample Group, described in Extension Point Deployment Sample.
This sample's primary application, Main.sbapp
, accepts stock trade tuples, then filters trades with volume over 1000 shares to a separate output port. If the LargeTrades
output port has a container connection to the input port of modules/LargeTradesLogHandler.sbapp
, then notification of large trades is written to the StreamBase log handler. On the other hand, if the LargeTrades
output port has a container connection to the input port of modules/LargeTradesErrorStreamHandler.sbapp
, then notification of large trades is passed to the StreamBase error stream mechanism. In both cases, announcements of large
trades appear in Studio's Console view.
This sample uses separate deployment files to select between the two run scenarios. To see the sample in action, do not run
Main.sbapp
or either module in the modules
folder. Instead, run one of the two StreamBase deployment files provided with the sample. This shows that the primary application
can be run with different sub-modules only by running different deployment files.
- samples/logging-logback
-
This sample provides:
-
A sample
logback.xml
configuration file that configures both a console appender and a rolling file appender. -
A server configuration file,
sbd.sbconf
, that sets a system property that locates thelogback.xml
file. The configuration file also puts thejava-bin
directory on the Java Build Path for use when running the sample at the command line. -
An EventFlow application that uses a custom Java operator to emit log messages.
-
A second EventFlow application that uses the StreamBase Log adapter to emit log messages.
-
A feed simulation file to send ten tuples to the input stream of the first sample, which generates ten log messages.
-
The deployment file sample is composed of following files:
File | Purpose |
---|---|
Main.sbapp |
The top-level application for this sample, with a simple Filter component to filter large trades. To run this sample, DO NOT RUN this EventFlow module. Instead, run one of the two StreamBase deployment files described next. |
LargeTradesErrorStream.sbdeploy |
A StreamBase deployment file that runs both Main.sbapp and LargeTradesErrorStreamHandler.sbapp in separate containers, and connects the LargeTrades output stream of Main.sbapp to the input stream of the second module.
|
LargeTradeLog.sbdeploy |
A StreamBase deployment file that runs both Main.sbapp and LargeTradesLogHandler.sbapp in separate containers. This deployment also connects the LargeTrades output stream of Main.sbapp to the input stream of the second module.
|
sbd.sbconf |
A server configuration file that adds the modules folder to the module search path. Used only for running the sample at the command prompt.
|
The following files are located in the modules subfolder of the sample_sbdeploy project folder.
|
|
LargeTradesErrorStreamHandler.sbapp |
An application intended to accept input from the LargeTrades output stream in Main.sbapp . To flag large trades, this module sends an event to the StreamBase error stream.
|
LargeTradesLogHandler.sbapp |
Another application intended to accept input from the LargeTrades output stream in Main.sbapp . To flag large trades, this module sends an event to the StreamBase logging facility using the Log adapter.
|
-
In the Package Explorer, open the
sample_sbdeploy
project folder. -
Double-click to open the
LargeTradesLogHandler.sbdeploy
deployment file. Make sure the Deployment File Editor is the currently active tab in Studio. -
Click the
Run button. This opens the SB Test/Debug perspective, opens
Main.sbapp
, and starts the two containers and application modules named in the deployment file. -
In the Manual Input view, confirm that the
TradesIn
input stream is selected. -
Enter the following field values:
Field Enter this value symbol IBM price 135.00 volume 200 -
Click Send Data, and a tuple arrives in the Application Output view. Observe that the tuple only appears on the
AllOtherTrades
output stream. -
Back in the Manual Input view, change only the
volume
field. Add a zero to change the 200 to 2000.Field Enter this value volume 2000 -
Click Send Data, and a tuple arrives in the Application Output view. Observe that this time, the large trade tuple arrived at both the
LargeTrades
output port of the primary module and thelargetradewatcher.out:Log_1
port of the secondary module. An announcement of the trade also appears as a WARN message in the Console view. -
Enter more tuples in the Manual Input view as desired.
-
When done, press F9 or click the
Stop Running Application button to stop the first deployment application.
-
Double-click to open the
LargeTradesErrorStream.sbdeploy
deployment file, and make sure the Deployment File Editor is the currently active tab in Studio. -
Click the
Run button to run this second deployment file. As before, this opens
Main.sbapp
and starts the two containers and application modules named in the second deployment file. -
Enter input tuples in the Manual Input view using steps similar to steps 5 through 8. Observe that large trade tuples only arrive on the
LargeTrades
output port and not from any port in the secondary module. Instead, large trade tuples are announced in the Console view with WARN messages. -
Enter more tuples in the Manual Input view as desired.
-
When done, press F9 or click the
Stop Running Application button to stop the second deployment application.
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 two terminal windows on UNIX, or two StreamBase Command Prompts on Windows. In both windows, navigate to your workspace copy of the sample.
-
In window 1, start StreamBase Server running the first deployment file. You must also specify the provided server configuration file so that the application can locate the module files in the
modules
subfolder. Enter:sbd -f sbd.sbconf LargeTradesLogHandler.sbdeploy
-
In window 2, type:
sbc enq TradesIn
The sbc command in window 3 now waits for keyboard input. Type:
IBM, 135.77, 200 IBM, 135.77, 2000
-
Observe that a WARN message appears in window 1 when the third field is over 1000.
-
In window 2, type: Ctrl+C to exit the sbc session.
-
In window 2, type the following command to terminate the server:
sbadmin shutdown
-
Now, back in window 1, run the second deployment file:
sbd -f sbd.sbconf LargeTradesErrorStream.sbdeploy
-
In window 2, type:
sbc enq TradesIn
-
In window 2, type:
IBM, 135.77, 2000
-
Observe that a WARN message appears in window 1, ending with
Evaluation exception: large trade
-
In window 2, type: Ctrl+C to exit the sbc session.
-
In window 2, type the following command to terminate the server:
sbadmin shutdown
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select
→ . -
Select StreamBase Deployment Files from the Application category.
-
Click OK.
StreamBase Studio creates a project for the sample.
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 the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:
studio-workspace
/sample_sbdeploy
See Default Installation Directories for the 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/sbdeploy
See Default Installation Directories for the default location of studio-workspace
on your system.