Apama Documentation : Developing Apama Applications : 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.
The following table describes EPL keywords and special identifiers. Some keywords are reserved only in the scope of a stream query in a monitor or in an Apama 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.
Keyword
Description / Syntax and Example
action
References or declares an action. Required in each action declaration.
Also an EPL 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");
See also: retain all.
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 block;
 
if x and y {myBlock;}
as
Specified to import an EPL plug-in, either a Java class or a C/C++ library.
import "plug-in-library" as identifier;
 
import "MyPlugin" as foo;
Specified to make event fields with different names but the same content appear to have the same name so they can be used as the key in an Apama query. Replace duration with a retain clause, a within clause, or both.
event1() key field1 duration;
event2() key field2 as field1 duration;
 
CarNum() key road within 1 hour;
Accident() key roadName as road within 1 hour;
Implicit coassignment of a matching event to a variable of this name in EPL listeners or queries. The variable type is implicitly the matching event type.
on all event_expression as variable action;
 
on all StockTick(*,*) as newTick processTick();
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;
between
In an Apama query, restricts which part of the pattern a within clause or a without clause applies to. Two or more identifiers can be specified in a between clause.
between (identifier1 identifier2 ...)
 
between (a b)
boolean
Boolean 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.
See the syntax and example for aggregate.
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.
See the syntax and example for group by and partition by.
catch
Part of a try...catch statement for handling exceptions.
See the syntax and example for 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
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();
send TestEvent(currentTime) to "output";
decimal
Type. Signed floating point decimal number with d at the end to distinguish it from a float type.
decimal identifier;
 
decimal exactValue;
exactValue := 1.2345d;
day
days
Part of a time literal you can specify in an Apama query within clause.
within integer day | days
 
within 3 days
dictionary
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 the syntax and example for if.
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. This statement will be deprecated in a future release. Use send...to instead.
emit event to channel;
 
emit newEvent to "com.apamax.pricechanges";
enqueue
Sends an event to the correlator's special queue for enqueued events. The event is then moved 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. Or, to send an event to the back of the input queues for a sequence of contexts, specify to sequence< context_expr>. This statement will be deprecated in a future release. Use send...to instead.
enqueue event_expr to context_expr;
enqueue event_expr to sequence<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.
In a monitor, 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
In an Apama query, specify every to aggregate values over multiple match sets.
find every event as coassignment
select_or_having_clause

 
find every A as a
select avg(a.x) as aax { }
false
Possible value of a Boolean variable.
find
In an Apama query, specifies the pattern of interest and a procedural block to execute when a match set is found.
find
   [every]
   query_event_pattern
   [where_clause]
   [within_clause]
   [without_clause]
   [select_clause]
   [having_clause] {
   block
   }
 
find
   Withdrawal as w1 -> Withdrawal as w2
   where w2.country != w1.country {
      log "Suspicious withdrawal: "
   }
float
Type. Signed floating point number.
float identifier;
 
float squareRoot;
for
Iterates over the members of a sequence and executes the enclosing statement or block once for each member.
for identifier in sequenceExpression {
...
}
 
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. In a monitor, valid as an identifier outside of a stream query.
from t in all Temperature()
within 60.0
having count() > 10
select mean(t.value)
In an Apama query find statement, restricts when procedural code block is executed.
having boolean_projection_expr
 
find every ATMWithdrawal as w
   having last(w.amount) > THRESHOLD
      * avg(w.amount)
   select last(w.transactionId) as tid {
   send SuspiciousTransaction(tid) to
      SuspiciousTxHandler;
   }
hour
hours
Part of a time literal you can specify in an Apama query within clause.
within integer hour | hours
 
within 5 hour
if
Conditionally executes a statement or block.
if booleanExpression [then] {
...
} [ else {
...
} ]
 
if floatVariable > 5.0 {
integerVariable := 1;
} else if floatVariable < -5.0 {
integerVariable := -1;
} else {
integerVariable := 0;
}
The then keyword can be optionally used between the condition and the first block. For example:
if floatVariable > 5.0 then {
integerVariable := 1;
}
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 the syntax and example for for.
Part of from statement.
See the syntax and example for from.
inputs
In an Apama query, there must be an input definition for each event type that the query operates on. The input definitions must be in the inputs section. The inputs section follows the parameters section, if there is one, and precedes the required find statement. See also Format of input definitions.
inputs {
event_type(event_filter)
key query_key
[within_clause]
[retain_clause]
[with_unique_clause]
[time_from_clause wait_clause
[or_clause]] ;
 
[ event_type(event_filter)
key query_key
[within_clause]
[retain_clause]
[with_unique_clause]
[time_from_clause wait_clause
[or_clause]] ; ]...
}

 
inputs {
Transaction() key
source as txSource,
dest as txDest
within PERIOD;
Acknowledgement() key
dest as txSource,
source as txDest
within PERIOD
}
integer
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"
key
In an Apama query input definition, the key clause identifies one or more fields in the input event types. The correlator uses these fields as the query key and partitions incoming events so that all events with the same key value are in their own partition.
key field_name [as field_name2] duration

inputs {
Withdrawal() key cardNumber within (period);
}
largest
Reserved for future use.
location
Type. An EPL 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;
millisecond
milliseconds
msec
Part of a time literal you can specify in an Apama query within clause.
within integer millisecond | milliseconds | msec
 
within 100 msec
minute
minutes
min
Part of a time literal you can specify in an Apama query within clause.
within integer minute | minutes | min
 
within 3 min
monitor
Declares a monitor. Required in each monitor definition. Braces enclose event type definitions, global variable declarations, and actions.
monitor monitor_name {
...
}
 
monitor SimpleShareSearch {
...
}
Specifies subscription to a named channel or unsubscription from a previously subscribed channel. Subscription/unsubscription statements are located in action blocks.

monitor.subscribe("channel_name");
monitor.unsubscribe("channel_name");
 
action start_trade()
{
// Subscribe to two channels:
monitor.subscribe("SOW_Ticks");
monitor.subscribe("IBM_Ticks");
}
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 block;
 
if not x myBlock;
on
Declares an event listener.
on [all] event_expression action;
 
on NewsItem("ACME",*) findStockChange();
Part of an equi-join clause.
See the syntax and example for join.
onBeginRecovery
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)
{ longDowntime:=true;
... // do something if
// downTime was long
}
}
onConcludeRecovery
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
Type. Container of zero elements or one element of a primitive or reference type.
optional<data_type> identifier;
 
optional<float> myOptFloat;
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 block;
 
if x or y 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;
parameters
If an Apama query specifies the optional parameters section, it must be the first section in the query. Parameters must be integer, float, string or boolean types. Specify one or more data_type  parameter_name pairs.
parameters {
data_type parameter_name
;
[ data_type parameter_name; ]...
}
 
parameters {
integer threshold;
float period;
}
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 that 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.";
query
Declares a query. Required in each query definition. Braces enclose the optional parameters section, required inputs section, required find statement, and optional action definitions.
query name {
[ parameters { parameters_block } ]
inputs { inputs_block }
find pattern block
[ action_definition ... ]
}
 
query FraudulentWithdrawalDetection2 {
inputs {
Withdrawal() key userId retain 3;
}
find Withdrawal as w1 -> Withdrawal as w2
where w1.city != w2.city {
log "Suspicious withdrawal: "
+ w2.toString() at INFO;
}
}
retain
In an Apama query input definition or in a stream query, specifies that the window contains only the last n events of this type that have been received.
retain windowSizeExpr
 
inputs {
Withdrawal() key userId retain 3;
}
 
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;
second
seconds
sec
Part of a time literal you can specify in an Apama query within clause.
within integer second | seconds | sec
 
within 3 sec
select
Identifies the item(s) you want the query to output.
In a monitor, this keyword is valid as an identifier outside a stream query.
select [rstream] selectExpr
 
from v in values
retain 10
select mean(v);
In an Apama query, a select clause aggregates event field values in order to find data based on many sets of events. A pattern that aggregates values specifies the every modifier in conjunction with select and/or having clauses.
select projection_expr as identifier
 
find every ATMWithdrawal as w
having last(w.amount) > THRESHOLD * avg(w.amount)
select last(w.transactionId) as tid {
send SuspiciousTransaction(tid) to
SuspiciousTxHandler;
}
send...to
Sends an event to the specified channel, context, or sequence of contexts. Contexts and external receivers subscribed to that channel receive the event.
send event_expr to channel;
send event_expr to context;
send event_expr to sequence<channel>;
 
send tick to "ticks-SOW";
sequence
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
References or declares a static action that applies to an event type.
static action static_action_name([arglist])
returns retType {
  do_something>;
}
 
event E {
static action someStaticAction(){
print "I am a static action on event type E";
}
}
stream
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
Type. Text string.
string identifier;
 
string message;
then
Optional part of conditional if statement.
See the syntax and example for if.
throw
Reserved for future use.
to
Indicates target of an emit, enqueue, send or spawn operation.
See examples for emit...to, enqueue...to, send...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.
See the syntax and example for aggregate.
unique
Part of the optional with unique clause in a stream query.
See the syntax and example for with unique.
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 monitor, an Apama query, or a stream query, allows use of an event type or 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;
In an Apama query, requires an amount of time to pass before or after the event pattern. The value must be a float or time literal. Typically used in conjunction with a without clause to detect the absence of an event before or after another event.
wait(value) as identifier
 
find wait(1 minute) as previous
-> DoorOpened as d without Unlock as u
where
Filter the items in the stream query's window or the items that result from a join operation.
In a monitor, 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)
In an Apama query, a where clause filters which events cause a match set. You can specify a find where clause that applies to the event pattern and you can also specify a without where clause that is part of a without clause. Any where clauses that you want to apply to the event pattern must precede any within or without clauses.
where booleanExpr
 
find LoggedIn as lc -> OneTimePass as otp
where lc.user = otp.user
within 30.0 {
emit AccessGranted(lc.user);
}
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.
while booleanExpression {
...
}
 
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 query or 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 query or 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);
In an Apama query, a within clause sets the time period during which events in the match set must have been added to their windows. The value of durationExpression must be a float literal or a time literal. A float literal always indicates a number of seconds.
within durationExpression
[ between ( identifer1 identifier2 ... ) ]
 
find Withdrawal as w1 -> Withdrawal as w2
where w2.country != w1.country
within 1 hour {
log "Suspicious withdrawal: "
+ w2.toString() at INFO;
}
without
In an Apama query find pattern, a without clause specifies that the presence of a particular event type prevents a match. Optionally, you can specify a where clause that filters which instances of the specified event type prevent a match and/or a between clause to restrict when the exclusion applies.
without typeId as coassignmentId
[ where boolean_expression ]
[ between ( identifier1 identifier2... )]
 
find OuterDoorOpened as od -> InnerDoorOpened as id
where od.user = id.user
without SecurityCodeEntered as sce
where od.user = sce.user {
emit Alert("Intruder "+id.user);
}
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 block;
 
if x xor y myBlock;
#
Escapes names of variables that clash with EPL keywords.
#identifier
 
print f.#integer.toString();
Copyright © 2013-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback