A choice element is a configurable element of a GeoEvent Service that routes GeoEvents, or event records, to one of several destinations based on specified conditions. They apply conditional statements to event records in order, much like an if-else statement in a programming language. A choice element can optionally be configured with an otherwise condition for event records whose attributes do not satisfy any of the other conditional statements.
Working with choice elements
A choice element specifies different routes a GeoEvent could take through a GeoEvent Service. A filter expression evaluates event record attributes to determine which route an event record will follow. An event record can only follow a single route and may be discarded if its attributes do not satisfy any of the specified conditions. If an event record's attributes do not satisfy the first filter expression (or condition) the next condition in the list is evaluated until all the specified conditional statements are considered. An optional otherwise condition can be used to catch event records whose attributes do not satisfy any other conditions. Filter expressions are considered one at a time, in a serial order, from the top (first) to the bottom (last).
If an event record does not meet any of the specified conditions, and an otherwise condition is not specified, the event record will be dropped and is not processed.
Example use cases
Below are some use cases for when a choice element could be used.
Transportation vehicle monitoring
In this example, assume a data feed provides event data for different types of transportation and each type must be processed differently. The data contains a field (VehicleType) that specifies one of three types of transportation vehicles (Airplane, Train, and Automobile). Using a choice element, each event record can be routed through a separate processing workflow based on the vehicle type. If an event record is received that is not one of the three types of vehicles such as Truck that record will be dropped since the Otherwise parameter is not checked.
Consider the following conditional statements applicable to this example:
- If the Vehicle Type equals Airplane, then process the event record as an airplane.
- If the Vehicle Type equals Train, then process the event record as a train.
- If the Vehicle Type equals Automobile, then process the event record as an automobile.
- If the Vehicle Type equals Truck, then drop the event record.
Snowplow speed monitoring
In this example, assume a data feed provides event data for a fleet of snowplow vehicles and their current speed. During plowing operations, the normal vehicle speed is between 25 and 35 miles per hour. Any deviation below this range indicates the snowplow is operating inefficiently and any deviation above this range may damage the snowplow.
Consider the following conditional statements that apply when the snowplow is plowing:
- If the Speed is less than or equal to 24 miles per hour, then the status of the snowplow will be Low Speed.
- If the Speed is greater than or equal to 36 miles per hour, then the status of the snowplow will be High Speed.
- Otherwise, the snowplow status will be Normal Speed.
Considerations when working with choice elements
Consider the following when working with choice elements.
- Each choice element requires at least one conditional statement.
- Defining an otherwise clause is optional and disabled by default.
- Each condition must route event records to exactly one filter or processor.
- Event records can only be routed to a choice element from an input, filter, or processor.
- Event records cannot be routed from one choice element to another choice element in series.
- Instead of putting a filter before or after a choice element, consider combining logical expressions into a single choice element.
- If you need to route event records from a single condition to two or more outputs, use a No Operation Processor as the target and branch to each output node from the processor.
- Instead of routing event records through a filter directly to a choice element, from a choice element to a filter, or from one choice element directly to a second choice element, it is recommended that you combine the conditions into a single filter expression.
For example, rather than using a filter to first identify event records with an attribute (for example, Speed > 65) and then using a choice element to handle specific cases (for example, VehicleType = Car, VehicleType = Truck, and VehicleType = Van) as shown in the first illustration below, you should instead combine the logical conditions into a choice element (for example, Speed > 65 AND VehicleType = Car) as shown in the next two illustrations.
Add a choice element to a GeoEvent Service
To add and configure a choice element in a GeoEvent Service, complete the following steps:
- In the service designer of GeoEvent Manager, drag a Choice element from the New Elements list onto the canvas.
- Enter a Name for the new choice element.
In a choice element, one or more conditional statements can be applied to the event data in the specified order. Each conditional statement has a unique name that identifies it as well as a number (starting with 1) that indicates the order in which the conditional statements will evaluate the event data.
- Click Add to add a conditional statement.
- In the Choice Properties window, follow the steps below to add a when clause.
- Enter a Name for the conditional statement.
- Click Add Expression to add and configure a when clause.
- Click Add Expression again to add and configure additional when clauses.
- Click OK to save the conditional statement.
- Repeat steps 3 and 4 above to add more conditional statements, as necessary.
- Optionally, check the Otherwise check box to define an otherwise route.
Checking the Otherwise check box enables an otherwise route. All events that do not meet the criteria defined by the when clauses will be passed to the otherwise route. If the Otherwise check box is not checked, any event records not meeting the defined when clauses will be dropped.
- Click OK to save and add the choice element to the service designer.
- Connect the new choice element to your other elements in the GeoEvent Service.
Edit a choice element
The Choice window provides options to review, edit, delete, and reorder configured conditional statements.
- Hover over to view the when clauses associated with a conditional statement.
- Use the Edit button to open and edit a conditional statement's when clauses.
- Use the Delete button to delete a conditional statement.
- Use the Reorder button to change the order of how the conditional statements evaluate the event data.
Using filters expressions in when clauses
In a when clause, different types of filter expressions can be used to evaluate the event data. For details on the different types of filtering options, see the resources below:
Vous avez un commentaire à formuler concernant cette rubrique ?