Apama 10.5.3 | Developing Apama Applications | Developing Apama Applications in EPL | Implementing Parallel Processing | Creating contexts
 
Creating contexts
In EPL, you refer to a context by means of an object of type context. The context type is a reference type.
The recommendation is to use private contexts and have monitor instances subscribe to the channels they require events from. This gives greater flexibility over using public contexts. For information on the constructors needed to create a context, see the description of the context type in the API Reference for EPL (ApamaDoc) .
The name of a context does not have to be unique, and is only used for diagnostic purposes (it is recommended that context names be meaningful and distinct). Creating a new context object with the same name as another context creates a reference to a different context, not the same context. Context references are independent to the actual context where monitors run. A context continues running if there are no references to it. A reference to a context may exist even though no active monitors are running in that context. You use the context reference to spawn to the context or send an event to the context. When you spawn to a context, the correlator creates the context if it does not already exist.
When you start a correlator, it has a single main context. You can then create additional contexts. Context reference objects are lightweight and creating one only creates a stub object and allocates an ID. In other words, when you create an EPL context object, you are actually creating a context reference.
The following example creates a reference, c, to a private context whose name is test:
context c:=context("test");
For information on the methods you can call on a context, see the description of the context type in the API Reference for EPL (ApamaDoc) .
See also How many contexts can you create?.