Developing Apama Applications > Developing Apama Applications in EPL > EPL Keyword Quick Reference
EPL Keyword Quick Reference
EPL is case-sensitive.
There are a number of identifiers that EPL has reserved for future use. In this release, if you use a reserved identifier, the correlator logs a warning. For a list of reserved identifiers, see List of identifiers reserved for future use in the "Lexical Elements" section of the Apama EPL Reference.
The following table describes EPL keywords and special identifiers. Some keywords are reserved only in the scope of a query. Where applicable, this is noted in the description. You can use an EPL keyword as an identifier if you prefix it with a hash symbol (#). See Escaping keywords to use them as identifiers in the "Keywords", "Lexical Elements" section of the Apama EPL Reference.
Keyword
Description
Syntax and Example
action
References or declares an action. Required in each action declaration.
Also an EPL data type.
action action_name([arglist])returns retType{
do_something>;
}
 
action notifyUser(){
log "Event sequence detected.";
}
aggregate
Keyword required in the definition of a custom aggregate function that can be used in a stream query.
aggregate [bounded|unbounded] aggregateName (
[arglist]) returns retType {
aggregateBody }
 
aggregate bounded wstddev( decimal x, decimal w )
returns decimal {
    do something}
all
Appears just before an event template to indicate that you want to continue listening for all instances of the specified event, and not just the first matching event.
all event_template
 
on all StockTick(*,*):newTick processTick();
Appears just before an event template that uses no other operators and creates a stream rather than an event listener. This is a stream source template, which continuously listens for all instances of the specified event and inserts all matching events into a newly created stream.
all event_template_with_no_other_operators
 
stream<Tick> ticks := all Tick(symbol=”APMA”);
and
Logical operator in an event expression.
on event_template and event_template action;
 
on A() and B() executeAction();
Logical operator in an
if
statement or other Boolean expression.
if ordinary_exp and ordinary_exp then block;
 
if x and y then {myBlock;}
as
Specified to import a correlator plug-in.
import plug-in as identifier;
 
import TimeFormatPlugin as foo;
at
Temporal operator in event expressions. Triggers a timer at a specific time or at repeated intervals.
at(minutes, hours, days_of_month, months,
days_of_week [,seconds])
 
on all at(5, 9, *, *, *) success;
Identifies the log level in a log statement.
log string [at log_level];
 
log "Your message here" at INFO;
boolean
Boolean data type. Value is true or false.
boolean identifier;
 
boolean marketOpen;
bounded
Optional keyword in a custom aggregate function definition. Indicates a function that can be used only with a bounded stream query window.
break
In a for or while statement, transfers control to the next statement following the block that encloses the break statement.
break;
by
Part of a partition by or group by clause in a stream query.
Valid as an identifier outside a stream query.
catch
Part of a try...catch statement for handling exceptions.
See try.
chunk
Data type. References a dynamically allocated opaque object whose contents cannot be seen or directly manipulated in EPL. Typically used to manage plug-in data.
chunk identifier;
 
chunk complexProductInfo;
completed
Event expression that matches only after all other processing on the matching event is completed.
on all completed event_expression action;
 
on all completed A(f < 10.0) {}
constant
Specifies an unchanging literal value.
constant type name := literal;
 
constant float GOLDEN := 1.61803398874;
context
Data type. Enables parallel processing.
context(string name)
context(string name, boolean receivesInput)
 
context c:=context("test");
continue
In a for or while statement, ends execution of the current iteration and transfers control to the beginning of the loop.
continue;
currentTime
Special EPL variable that returns the current time in the correlator.
log currentTime.toString();
emit TestEvent(currentTime);
decimal
Data type. Signed floating point decimal number with d at the end to distinguish it from a float data type.
decimal identifier;
 
decimal exactValue;
exactValue := 1.2345d;
dictionary
Data type. Stores and retrieves data based on a key.
dictionary <key_type, data_type> identifier;
 
dictionary <integer, string> myOrders;
die
Terminates execution of the monitor instance.
die;
 
on NewStock (chosenStock.name,
chosenStock.owner) die;
else
Part of an if statement.
See example of if. statement.
emit
Publishes an event on the correlator’s output queue.
emit event;
 
emit newEvent;
emit...to
To publish an event to a named channel of the correlator’s output queue, specify to channel.
emit event to channel;
 
emit newEvent to "com.apamax.pricechanges";
enqueue
Sends an event to the back of the input queue of each public context.
enqueue event;
 
enqueue newEvent;
enqueue ...to
To send an event to the back of the input queue of a particular context specify to context_expr.
enqueue event_expr to context_expr;
 
enqueue tick to c;
event
Declares an event type.
Required in each event type definition.
event event_type {
[ [wildcard] field_type field_name; |
constant field_type field_name := literal; |
action_definition ... ]
}
 
event StockTick {
   string name;
   float price;
}
every
In a stream query, if you specify a within window, specification of every updates the window every batchPeriodExpr seconds.
The every keyword is valid as an identifier outside a stream query.
every batchPeriodExpr
 
from v in values
within 3.0 every 3.0
select v
If you specify a retain window without also specifying within, specification of every updates the window after every batchSizeExpr items are received.
every batchSizeExpr
 
from v in values
retain 3 every 3
select v
false
Possible value of a Boolean variable.
 
float
Data type. Signed floating point number.
float identifier;
 
float squareRoot;
for
Iterates over the members of a sequence and executes the enclosing statment or block once for each member.
forStatement ::= for counter
in sequenceblock;
 
for i in s { 
print i.toString();
}
from
Introduces a stream query definition. Specifies the stream, and optionally a window (stream subset), that the stream query is operating on.
from itemIdentifier in streamExpr
[windowDefinition]
 
from t in ticks retain 3
Two consecutive from clauses specify a cross-join, which combines items from two streams to create one stream.
from itemIdentifier in streamExpr
[windowDefinition]
from itemIdentifier in streamExpr
[windowDefinition]
 
from x in letters retain 2
from y in numbers retain 2
select P(x,y)
Specifies a stream listener that obtains items from a stream and passes them to procedural code.
[listener :=] from streamExpr :
identifier statement
 
float p;
from t in all Tick(symbol="APMA")
   select t.price : p {
   print "'APMA' price is: " +
p.toString();
}
group by
Controls how a stream query groups data when generating aggregate output items.
It is valid to use group as an identifier outside a stream query.
group by groupByExpr [, groupByExpr]...
 
from t in ticks
within 60.0 group by t.symbol
select mean(t.price)
having
Filter the items coming out of a stream query's aggregate projection. Valid as an identifier outside of a stream query.
from t in all Temperature()
within 60.0
having count() > 10
select mean(t.value)
if
Conditionally executes a statement or block.
ifStatement ::=
if booleanExpression then block
| if booleanExpression
then block else block
| if booleanExpression
then block else  ifStatement block
::= {
statementList
}
 
if floatVariable > 5.0 then {
integerVariable := 1;
} else if floatVariable < -5.0 then {
integerVariable := -1;
} else {
integerVariable := 0;
}
import
Loads a plug-in into the correlator and makes it available to your monitor, event, or aggregate function.
import "plug-in_name" as identifier;
 
import "complex_plugin" as complex;
in
Identifies range membership in an event expression.
on event_name(event_field in [range])
 
on all A(m in [0:10])
Part of for statement.
See for statement example.
Part of from statement.
See from statement example.
integer
Data type. Negative, zero, and positive integers.
integer identifier;
 
integer count;
join
Combines matching items from two streams to create one stream. This is an equi-join.
Valid as an identifier outside a stream query.
join itemIdentifier in streamExpr
[windowDefinition]
on joinKeyExpr1 equals joinKeyExpr2
 
from r in priceRequest
join p in prices
partition by p.symbol retain 1
on r.symbol equals p.symbol
select p.price
Built-in method on strings that concatenates a sequence of strings.
join(sequence<string> s)
 
sequence<string> s :=
["Something", "Completely", "Different"];   
print ", ".join(s);
This prints the following:
"Something, Completely, Different"
largest
Reserved for future use.
location
Data type. An EPL data type used to describe rectangular areas in a two-dimensional, unitless, Cartesian, coordinate plane. Locations are defined by the float coordinates of two points x1, y1 and x2, y2 at diagonally opposite corners of an enclosing boundary rectangle.
location(15.23, 24.234, 19.1232, 28.873)
log
Writes messages and accompanying date and time information to the correlator’s log file
log string [at log_level];
 
log "Your message here" at INFO;
monitor
Declares a monitor. Required in each monitor definition. Braces enclose event type definitions, global variable declararions, and actions.
monitor monitor_name {
...
}
 
monitor SimpleShareSearch {
...
}
new
Allocates a new object.
new typeName;
 
b := new Foo();
not
Logical operator in an event expression.
not event_template
 
on A() and not B() executeAction();
Logical operator in an if statement or other Boolean expression.
if not ordinary_exp then block;
 
if not x then myBlock;
on
Declares an event listener.
on [all] event_expression action;
 
on NewsItem("ACME",*) findStockChange();
Part of an equi-join clause.
See join.
onBegin Recovery
If defined, action that the correlator executes when the correlator restarts.
Note that onBeginRecovery is not a keyword. It is a special identifier. It is good practice to refrain from using this identifier for any other purpose.
action onBeginRecovery() { }
 
action onBeginRecovery() {  
if (timeFormatPlugin.getTime() -
currentTime > (60.0 * 60.0 * 2)
then
{ longDowntime:=true;
... // do something if
// downTime was long
}
}
onConclude Recovery
If defined, action that the correlator executes when the correlator finishes recovery.
Note that onConcludeRecovery is not a keyword. It is a special identifier. It is good practice to refrain from using this identifier for any other purpose.
action onConcludeRecovery() { }
 
action onConcludeRecovery() {    
initiateListener(); // go back
//to normal
}
ondie
If defined, action that the correlator executes when a monitor instance terminates.
Note that ondie is not a keyword. It is a special identifier. It is good practice to refrain from using this identifier for any other purpose.
action ondie() { }
 
action ondie() {    
log "sub-monitor terminating for "
+ myId;
route InternalError("Foo");
}
onload
Name of the action that the correlator executes when you inject a monitor. Every monitor must declare an onload action.
Note that onload is not a keyword. It is a special identifier. It is good practice to refrain from using this identifier for any other purpose.
action onload(){ ... }
 
action onload() {   
on all StockTick(*,*):newTick {
processTick();   
}
}
onunload
If defined, action that the correlator executes when the last instance of a particular monitor terminates.
Note that onunload is not a keyword. It is a special identifier. It is good practice to refrain from using this identifier for any other purpose.
action onunload() { };
 
action onunload() {   
route LastMonitorTerminating();
}
optional
Reserved for future use.
or
Logical operator in an event expression.
on event_template or event_template action;
 
on A() or B() executeAction();
Logical operator in an if statement or other Boolean expression.
if ordinary_exp or ordinary_exp then block;
 
if x or y then myBlock;
package
Mechanism for adding context to monitor and event names. Monitors and global events in the same package must each have a unique name within the package.
package identifier;
 
package com.apamax.orders;
partition
by
Effectively creates a separate window for each encountered distinct value of the partition by expression.
partition is valid as an identifier outside a stream query.
partition by partitionByExpr
[, partitionByExpr]...
 
from t in all Tick()
partition by t.symbol
retain 10 with unique t.price
select t.price
persistent
At the beginning of a monitor declaration, indicates you want that monitor to be persistent.
persistent monitor string
 
persistent monitor ManageOrders
print
Writes textual messages followed by a newline to the correlator’s standard output stream — stdout.
print string;
 
print "Your message here.";
retain
Specifies a stream query window that contains only the last n items received.
Valid as an identifier outside a stream query.
retain windowSizeExpr
 
from v in values
retain 10
select mean(v)
retain all
Specifies a stream query window that aggregates values calculated over the lifetime of the query. This is an unbounded window.
retain all
 
from v in values
retain all
select mean(v)
return
In an action body, specifies the value to return from that action. Required if an action returns a value.
returns typeToReturn
return retValue
 
action complexAction(
integer i, float f) returns string {   
// do something  
return "Hello";
}
returns
In an action declaration, specifies the type of value returned by an action. Required if an action returns a value.
Also used in custom aggregate function declarations and when naming action types.
See previous example.
route
Sends an event to the front of the current context’s input queue.
route event();
 
route StockTick();
rstream
In a query with a window definition and a simple projection, indicates that you want the query to output its remove stream, that is, the items it removes from the window.
Specification of rstream in an aggregate projection is not useful so it is not allowed.
Valid as an identifier outside a stream query.
select [rstream] selectExpr
 
from i in inputs
retain 2
select rstream i;
select
Identifies the item(s) you want the query to output.
This keyword is valid as an identifier outside a stream query.
select [rstream] selectExpr
 
from v in values
retain 10
select mean(v);
sequence
Data type. Ordered set or array of entries whose values are all of the same primitive or reference type.
sequence<data_type> identifier;
 
sequence<float> myPrices;
smallest
Reserved for future use.
spawn
Creates a copy of the currently executing monitor instance.
spawn action([parameter_list]);
 
action onload() {   
spawn forward("a", "channelA");   
spawn forward("b", "channelB");
}
spawn...to
To create a copy of the currently executing monitor instance in the specified context specify spawn with tocontext_expr.
spawn action([arg_list]) to context_expr;
 
spawn doCalc(cal) to context(“Calculation”);
static
Reserved for future use.
stream
Data type. Refers to a stream of items. An item can be a boolean, decimal, float, integer, string, location, or event type.
stream<type> name;
 
stream<decimal> prices;
streamsource
Reserved for future use.
string
Data type. Text string.
string identifier;
 
string message;
then
Part of conditional if statement.
See example for if.
throw
Reserved for future use.
to
Indicates target of an emit, enqueue, or spawn operation.
See examples for emit...to, enqueue...to, and spawn...to.
true
Possible value of a Boolean variable.
try
Part of a try...catch statement for handling exceptions.
try block1
catch(Exception variable) block2
try {
return float.parse(prices[fxPair]);
} catch(Exception e) {
return 1.0;
}
unbounded
Optional keyword in a custom aggregate function definition. Indicates a function that can be used with only an unbounded (retain all) stream query window.
unique
Part of the optional with unique clause in a stream query.
unmatched
Except for completed and unmatched event expressions, the event is not a match with any event expression currently within the context.
on all unmatched event_expression[:coassignment]
action;
 
on all unmatched Tick():tick processTick();
using
In a stream query, allows use of a custom aggregate function that is defined in another package.
using packageName.{aggregateName|eventName};
 
using com.apamax.custom.myAggregateFunction;
wait
Temporal operator in an event expression. Inserts a pause in an event expression. Once activated, a wait expression becomes true automatically once the specified amount of time passes.
wait(float)
 
on A() -> wait(10.0) -> C() success;
where
Filter the items in the stream query’s window or the items that result from a join operation.
Valid as an identifier outside a stream query.
where booleanExpr
 
from t in ticks
retain 100 where t.price*t.volume>threshold
select mean(t.price)
while
Repeatedly evaluates a boolean expression and executes an enclosed statement or block as many times as the expression result is found to be true.
whileStatement ::= while booleanExpression
block

 
while integerVariable > 10 {   
integerVariable := integerVariable – 1;   
on StockTick(
"ACME", integerVariable) doAction(); }
wildcard
In an event type definition, indicates a parameter that you will never specify as a match criteria in an event template.
wildcard param_type param_name;
 
event StockTick {   
string name;   
float price;   
wildcard string exchange;
}
with unique
In a stream query, if there is more than one item in the window that has the same value for the key identified by keyExpr, only the most recently received item is part of the result set.
with and unique are valid as identifiers outside a stream query.
with unique keyExpr
 
from p in pairs
retain 3 with unique p.letter
select sum(p.number)
within
Temporal operator in an event expression. Specifies a time limit for the event listener to be active.
within(float)
 
on A() -> B() within(30.0) notifyUser();
In a stream query, specifies a window that contains only those items received in the last windowDurationExpr seconds.
within windowDurationExpr
 
from v in values
within 20.0
select mean(v);
xor
Logical exclusive or operator that can apply to an event template.
xor event_template
 
on A() xor B() notifyUser();
Logical operator in an if statement or other Boolean expression.
if ordinary_exp xor ordinary_exp then block;
 
if x xor y then myBlock;
#
Escapes names of variables that clash with EPL keywords.
#identifier
 
print f.#integer.toString();
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.