Skip To Content

What are choices?

Choices are configurable elements of GeoEvent Services that route GeoEvents, or event records, to more than one destination based on specified conditions. Choices are configurable elements that use conditional statements applied to the event records in order, much like an if-else statement in programming languages. In addition to the conditional statements, an optional final route can be defined for events that do not pass the list of specified conditional statements.

How do choices work?

As mentioned above, a choice specifies a list of routes a GeoEvent could take. Each route is evaluated by a when clause that defines the conditional statement an event must meet to pass through. If an event passes the condition defined by the when clause, it follows that route. If an event does not pass the condition defined by the when clause, it passes to the next when clause if one exists. The when clauses in a choice are processed in a serial order, all configurable in the choice element.

If an event record does not meet any of the conditions specified in the when clause(s), it can optionally be passed to an otherwise route. If an otherwise route is enabled, the event is passed to that route, there is no condition that must be met. If an otherwise route is not enabled, the event record is dropped and is not passed to any route.

Nota:

An event record that meets the condition in a given when clause will not be considered for any subsequent when or otherwise routes.

Example 1: Transportation vehicle monitoring

In this example, assume a given data feed provides event data for different types of transportation vehicles, each must be processed differently. The data contains a field (VehicleType) that contains information about three different types of transportation vehicles (Airplane, Train, or Automobile). Using a choice element, each event record can be routed to a separate processing workflow based on the vehicle type. If the data feed sends an event record that is not one of the three vehicle types such as Truck the event is dropped.

Example conditional statements in Choice dialog

Consider the following conditional statements applicable to this example:

  • If VehicleType equals Airplane, then process the event record as an airplane.
  • If VehicleType equals Train, then process the event record as a train.
  • If VehicleType equals Automobile, then process the event record as an automobile.
  • If VehicleType equals Truck, then drop the event record.

Example conditional statements

Example 2: 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 plow.

Example conditional statements in Choice dialog

Consider the following conditional statements which 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.

Example conditional statements

Considerations when working with choices

There are many considerations when working with choice's including:

  • Each choice requires at least one conditional statement.
  • Defining an otherwise clause is optional and disabled by default.
  • Each choice element can have only one parent element and that parent element must be either an input, a filter, or a processor.
  • The target of a choice element must be either empty (no target), a processor, a filter, or an output.
  • A choice element cannot route to another choice element, meaning two choice elements cannot be placed in a row in a GeoEvent Service:
    • The input to a choice cannot be the output of another choice.
    • The target of a choice cannot be another choice.
  • If a use case requires the target of one choice element be routed to a second-choice element:
    • Use a No Operation Processor in between the two choice elements.
    • Or include the when clause(s) from the second choice into the first choice.

Add a choice to a GeoEvent Service

To add and configure a choice element in a GeoEvent Service, follow the steps below.

  1. In the service designer, drag and drop a Choice element from the New Elements list onto the canvas. The Choice dialog will open.

    Add a Choice dialog

  2. Enter a Name for the new choice element.
    Nota:

    In a choice, one or more conditional statements can be applied, in a specified order, to the event data. 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.

  3. Click Add to add a conditional statement.

    Add a conditional statement

  4. In the Choice Properties dialog, follow the steps below to add a when clause.

    Choice Properties dialog

    1. Enter a Name for the conditional statement.
    2. Click Add Expression Add expression button to add and configure a when clause.
    3. Click Add Expression Add expression button again to add and configure additional when clause(s).
    4. Click Ok to save the conditional statement.
  5. Repeat steps 3 and 4 above to add additional conditional statements, as necessary.
  6. Optionally, check the Otherwise checkbox to define an otherwise route.

    Otherwise route option

    Nota:

    Checking the Otherwise checkbox enables an otherwise route. All events that do not meet the criteria defined by the when clause(s) will be passed to the otherwise route. Unchecking the Otherwise checkbox means any event records not meeting the defined when clause(s) will be dropped.

  7. Click Ok to save and add the choice element to the service designer canvas.
  8. Connect the new choice element to the other elements in the GeoEvent Service.

Edit a choice

The Choice dialog provides options to review, edit, delete, and reorder configured conditional statements.

  • Hover over Info button to view the when clause(s) associated with a conditional statement.
  • Click Edit button to open and edit a conditional statement's when clause(s).
  • Click Delete button to delete a conditional statement.
  • Use Reorder button to change the order of the how the conditional statements evaluate the event data.

Using filters in when clauses

In a when clause, you have the option to use different types of filters to evaluate the event data. For details on the different types of filtering options, see the resources below.