Chapter 3. Scenario Interpreter (%esperscenario)

3.1. Set or Advance to a Given Time
3.2. Sending an Event
3.2.1. Nested Events
3.3. Advance Time Relative to the Current Time
3.4. Customizing Output

A paragraph that contains a scenario consisting of a sequence of events and time must begin with %esperscenario.

A scenario is a list of instructions with one instruction per line. Each instruction can either:

When running a paragraph that contains a scenario, the notebook performs these actions:

  1. Allocates a runtime.

  2. Sets the runtime current time.

  3. Deploys all EPL that compiled successfully.

  4. Validates and executes each instruction.

  5. Displays EPL statement output events, by default as an HTML table.

When running a scenario, the default start time is 1970-01-01 00:00:00.000 unless the scenario, in the first instruction, sets another given time.

Current time is represented by a predefined long-type millisecond value by name t.

To set a time or advance to a given time, enter an assignment of time t to a string date-time value as follows:

t = "2001-01-01 08:00:00.000"

If the time is newer than the current time the time advances to the provided time.

To send an event, enter an assignment of event type name to an array of name-value pairs in curly braces. For example:

MyEvent = {intProperty = 0, stringProperty = 'abc'}

You may use curly braces for array and collection values, like shown here:

MyEvent = {stringArray = {'a', 'b'},  listProperty = {1, 2, 3}}

The scenario interpreter converts array values to the given type, for example when the event type was declared as create schema MyEvent(stringArray string[]) the interpreter converts values for stringArray to array of string. For object-array please use java.lang.Object[] as type. The interpreter supports array values for these types as well: java.util.Collection, java.util.List, java.util.ArrayList and java.util.Vector.

To assign the value of an EPL expression evaluation to an event property, use the eval function and specify the expression string. The next example assigns the result of the expression 5*5 to intProperty and the result of the myFunction function to stringProperty.

MyEvent = {intProperty = eval("5*5"), stringProperty = eval("myFunction('some value')")}

To assign a value to a Date or Calendar-typed event property you may specify a string-value that contains a datetime value following one of these formats:

For example:

MyEvent = {dateOrCalendarPropertyOne = '2002-09-30 9:00:00', dateOrCalendarPropertyTwo = '2002-09-30 9:00:00.000', dateOrCalendarPropertyThree = '2002-09-30 9:00:00.000+0100'}

To advance time relative to current time, enter an assignment of time t to t plus a time period. For example:

t = t.plus(10 minutes 5 seconds)

The EPL "plus" date-time enumeration method and the time period parameter documentation in Esper docs have more information.

Alternatively, you may also advance time in millisecond steps by adding milliseconds to t:

t = t + 1000

The above example adds 1 second (1000 milliseconds) to the current time.

You can create a separate paragraph, specify %espersetup setup and run that paragraph. After running the paragraph presents a form with output options.

You can decorate your statements with the @Audit annotation for audit-level information on statement execution (use a %espersetup setup paragraph to enable audit output).