- Index

< Previous |  | Next >

# LiveView Alert Configuring Output Adapter

## Introduction

The TIBCO® LiveView Alert Configuring Output Adapter allows a StreamBase application to list, create, modify, and remove alerts from LiveView servers.

## Properties

This section describes the properties you can set for this adapter, using the various tabs of the Properties view for the adapter's icon in StreamBase Studio.

### General Tab

Name: Use this required field to specify or change the component's name, which must be unique in the current module. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.

Adapter: A read-only field that shows the formal name of the adapter.

Class name: Shows the fully qualified class name that implements the functionality of this adapter. If you need to reference this class name elsewhere in your application, you can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.

Start with application: If this field is set to Yes (default) or to a module parameter that evaluates to `true`, this instance of this adapter starts as part of the JVM engine that runs this EventFlow fragment. If this field is set to No or to a module parameter that evaluates to `false`, the adapter instance is loaded with the engine, but does not start until you send an epadmin container resume command (or its sbadmin equivalent), or until you start the component with StreamBase Manager.

Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports to learn about Error Ports.

Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.

### Adapter Properties Tab

This section describes the properties on the Adapter Properties tab in the Properties view for the LiveView Alert Configuration adapter.

Property | Description
--- | ---
Set Server URI to encapsulating LiveView | Select this check box when the adapter is part of a LiveView project. In this case, the adapter connects to the port of the running LiveView server. When authentication is enabled, the credentials used to connect to the LiveView server are retrieved from the `liveview.internal.username` and `liveview.internal.password` system properties. The corresponding LiveView user must be configured with the appropriate permissions to allow this adapter to perform its operations.
LiveView Server URI | A LiveView server URI, or an expression or variable that resolves to a LiveView server URI. For example, the URI for the local machine and default port is `lv://localhost:10080`.
Connect Inline | If the adapter is not currently connected to the configuration LiveView server, a new attempt is made when a command tuple arrives. When not connected the adapter periodically tries to connect to the server, so Connect InLine is simply a means of forcing an immediate attempt.
Log Level | Controls the level of verbosity the adapter uses to send notifications to the console. This setting can be higher than the containing application's log level. If set lower, the system log level is used. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE.

### Concurrency Tab

Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.

### Caution

Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.

## Using the Adapter in a StreamBase Application

The LiveView Alert Configuration adapter provides one input port and two output ports:

- The input port sends commands and configuration information to the adapter to list, create, update, or delete alerts.

- The Status output port emits tuples that provide information about each command, and the status of the connection to the configured LiveView server.

- The other output port provides alert configuration information, such as when listing alerts.

As with StreamBase adapters and operators, you can optionally enable an Error Output Port, as described in Using Error Ports and Error Streams.

Each successful input tuple command results in an output tuple from the result output port. For get, create, and update commands, the output AlertRuleList will have the resulting AlertRule tuples. If a command is unsuccessful the Status port emits a tuple with information regarding the failure.

### LiveView Alert Configuration Adapter Input Port

The input port requires two fields be defined. The first is a string Command field and the second is a tuple field that contains all the Alert configuration information.

Field | Data Type | Description
--- | --- | ---
Command | string | The table command to execute which must be one of the following strings:
getalertrules — Requests one or more alert rules. These are send to the output port one alert at a time. | updatealertrule — Requests an existing alert rule be updated. Non-null fields in the AlertRule tuple will be updated.
createalertrule — Requests an alert rule be created. The AlertRule tuple field must have the configuration information. | deletealertrule — Requests an existing alert rule be deleted.
AlertRule | tuple | A tuple that contains all the alert rule configuration information.

The AlertRule tuple has all the Alert configuration information. The tuple fields are defined in the table below. Note that for updatealertrule only non-null fields are updated.

Field | Data Type | Description
--- | --- | ---
AlertID | string | AlertID is used to identify a specific alert you wish to delete, update, or get. AlertID is ignored when creating an alert as the server generates the AlertID.
AlertName | string | The name of the alert.
User | string | For getalertrules return alerts for this user name. For createalertrule and updatealertrule use this user name if auth is not enabled.
StatusMessage | string | Set by the server to indicate the current status of an alert. A string of `OK` means the alert is good.
QueryConfig | tuple | The QueryConfig to use with this alert see QueryConfigSchema below.
CronString | string | A Quartz Scheduler cron string.
Description | string | The description of the alert.
Message | string | The message that will be used for the alert.
Severity | int | The severity of the alert — a somewhat arbitrary number.
Quiescence | int | The amount of time in milliseconds to ignore conditions after the alert has triggered.
IsEnabled | boolean | Indicates if the entire alert is enabled or not.
Created | timestamp | The creation time of the alert. Set only by the server.
LastUpdated | timestamp | The last updated time of the alert. Set only by the server.
IsValid | boolean | Set by the server to indicate if an alert is valid or not.
AlertActionPublish | list | A list of AlertActionPublishSchema tuples the define the publish actions for the alert.
AlertActionJava | list | A list of AlertActionJavaSchema tuples the define the Exec Java actions for the alert.
AlertActionOS | list | A list of AlertActionOSSchema tuples the define the Exec OS actions for the alert.
AlertActionDelete | list | A list of AlertActionDeleteSchema tuples the define the Delete actions for the alert.
AlertActionLvPublish | list | A list of AlertActionLVPublishSchema tuples the define the LiveView publish actions for the alert.
AlertActionEmail | list | A list of AlertActionEmailSchema tuples the define the email actions for the alert.
AlertActionSendTuple | list | A list of AlertActionSendTupleSchema tuples the define the publish actions for the alert.

The QueryConfigSchema tuple has QueryConfig settings for the alert.

Field | Data Type | Description
--- | --- | ---
Predicate | string | The simple predicate used to trigger the alert.
Projections | string | Used for aggregate alert expressions.
TableName | string | The table name the predicate applies to.
QueryType | string | One of snapshot, snapshot_and_continuous, or continuous. Continuous is the default.

The AlertActionPublishSchema tuple configures the Alert action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
MessageTemplate | string | Sets the value of the actions messageTemplate.
AlertKey | string | The primary key value that will be used in the LVAlerts table. A null value result in a unique key generated on the server for each Alert publish action.
Recipient | string | The value used in the LVAlert Recipient field.

The AlertActionJavaSchema tuple configures the Alert Exec Java action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
ClassName | string | The name of the Java class to execute. This class must implement the `ExecJavaAction` interface.
Params | list | A list of AlertParamSchema tuples. Used to supplied parameters to the implementing `ExecJavaAction` class.

The AlertActionOSSchema tuple configures the Alert Execute OS command action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
Command | string | The command string to execute.

The AlertActionDeleteSchema tuple configures the Alert Delete Query action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
TableName | string | The name of the table to issue the delete query on.
Predicate | string | The predicate to use for the delete.

The AlertActionLVPublishSchema tuple configures the Alert LiveView Publish action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
LVURI | string | The LiveView URI to publish to.
TableName | string | The name of the table to publish to.
Substitutions | list | A list of AlertParamSchema tuples. Used to supplied field value substitutions for the published LiveView tuple.

The AlertActionEmailSchema tuple configures the Alert Email action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for.
IsEnabled | string | True if the action is enabled, false if the action disabled.
To | list | A string list of email addresses to send to.
CC | list | A string list of email addresses to send carbon copy.
BCC | list | A string list of email addresses to send blind carbon copy.
Subject | string | The subject of the email.
Body | string | The body of the email.

The AlertActionSendTupleSchema tuple configures the Alert Send Tuple action.

Field | Data Type | Description
--- | --- | ---
Description | string | The description of what this action is for
IsEnabled | string | True if the action is enabled, false if the action disabled.
SBURI | string | Sets the value of the actions messageTemplate
InputStream | string | The primary key value that will be used in the LVAlerts table. A null value result in a unique key generated on the server for each Alert publish action.
Substitutions | list | A list of AlertParamSchema tuples. Used to supplied field value substitutions for the tuple being sent.

The AlertParamSchema tuple provides key value pairs for parameter substitutions

Field | Data Type | Description
--- | --- | ---
ParamName | string | The name of the parameter
ParamValue | string | The value of the parameter

### LiveView Alert Configuration Adapter Output Ports

The LiveView Alert Configuration adapter has two output ports — one output status port and one AlertOut port.

The status port reports connection issues with the LiveView server and problems that may arise from alert configuration commands.

- A CONNECTION message shows the success or failure of the connection to the LiveView server.

- For failing Alert commands, an ALERT* message shows FAILED or ERROR it its Action field, with an explanatory note in the Message field.

The status port uses the fields shown in the following table:

Field | Data Type | Description
--- | --- | ---
Type | string | The basic state reported, always one of the following:
CONNECTION | ALERT_LIST
ERROR | ALERT_DELETE
ALERT_SET | ALERT
Object | string | The name on the EventFlow canvas of the adapter reporting the status.
Action | string | The action that occurred, one of the following:
CONNECTED | ERROR
FAILED |
Message | string | A human-readable string that provides additional context for the status message.
Time | timestamp | The time the publish request or error occurred.

The Alert output port has the Command sent by the input tuple and a list of AlertRuleSchema tuples.

Field | Data Type | Description
--- | --- | ---
Command | string | The table command to execute which must be one of the following strings:
getalertrules — Requests one or more alert rules. These are send to the output port one alert at a time. | updatealertrule — Requests an existing alert rule be updated. Non-null fields in the AlertRule tuple will be updated.
createalertrule — Requests an alert rule be created. The AlertRule tuple field must have the configuration information. | deletealertrule — Requests an existing alert rule be deleted.
AlertRule | tuple | A tuple that contains all the alert rule configuration information.

### Adding the Adapter to an EventFlow Application

Add an instance of the adapter to a new EventFlow application with the following steps:

1. In StreamBase Studio, create a project, including an empty StreamBase EventFlow application file to host the adapter.

2. From the Operators and Adapters drawer of the Palette view, drag the Adapters, Java Operators icon to the canvas. This opens the Insert an Operator or Adapter dialog.

3. In the search field, type a string such as `liveview` to narrow the list of adapters. Select the icon for the LiveView Alerts adapter, then click OK.

4. Double-click the adapter's icon and select the Adapter Properties tab in the Properties view.

5. Next, either:

   1. If this adapter is part of an EventFlow module that is itself part of a LiveView project, select the Set Server URI to encapsulating LiveView check box. This check box tells the adapter to connect to the host and port for the current project's LiveView server.

   2. Or specify the URI for a local or remote LiveView server to connect to (or accept the default URI, `lv:/localhost:10080`).

6. Add an Input Stream and connect an arc from it to the LiveView Alert adapter's input port.

7. Specify the schema for the Input Stream as described in the LiveView Alert adapter input port.

8. Add an Output Stream and connect an arc to it from the LiveView Alert adapter's output port.

9. At runtime, send a tuple to this module's input port, specifying the alert command you wish to perform.

## Typechecking and Error Handling

The LiveView Alert Configuration adapter uses typecheck messages to help you configure the adapter.

The adapter generates warning messages at runtime under various conditions, including:

- The configured LiveView server is not available.

## Suspend and Resume Behavior

When suspended, the adapter stays connected to the LiveView server, but no longer processes input tuples. On resume, the adapter continues to process new input tuples.