Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Implementing Parallel Processing : Obtaining context references
Obtaining context references
To obtain a reference to the context that a piece of code is running in, call the context.current() method. This is a static method that returns a context object that is a reference to the current context. The current context is the context that contains the EPL that calls this method.
For a monitor instance to interact with the EPL by means of a context object in another context, the monitor instance must have a reference to that context. A monitor instance can obtain a reference to another context in only the following ways:
*By creating the context.
*By receiving a context reference, which must be of type context. A monitor instance can receive this reference by means of a routed or sent event, or a spawn operation.
For example:
on all Calculate() as calc {
   integer calcId:=integer.getUnique();
   spawn doCalculation(calc, calcId, context.current())
      to context("Calculation");
do something
}
action doCalculation(Calculate req, integer id, context caller) {
   do something   
send CalculationResponse(id, value) to caller;
}
If a monitor instance that creates a context does not send a context reference outside itself, and does not subscribe to any channels, no other context can send events to that context, except by means of EPL plug-ins. This affords some degree of privacy for the context.
A context object (a context reference) does not do anything. It is simply the target of the following:
*spawn ActionIdentifier([ArgumentList]) to ContextExpression;
See Spawning to contexts.
*send EventExpression to ContextExpression;
See Sending an event to a particular context.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback