context
Values of the context type are references to contexts. A context lets EPL applications organize work into threads that the correlator can concurrently execute.
Usage
Use one of the following constructors to create a context reference:
context(string name)
context(string name, boolean receivesInput)
The optional receivesInput Boolean flag controls whether the context is public or private:
true — A public context can receive external events on the default channel, which is the empty string (
""). There is no requirement for a monitor instance in this context to subscribe to the default channel.
false — A private context does not receive external events on the default channel. This is the default.
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.
A context is subscribed to the union of the channels each of the monitor instances in that context is subscribed to. This is a property of the monitor instances running in a context and is not accessible by means of the context reference object.
Methods
After you create a context, you can call the following instance methods on that context:
ContextMethods
current() — Returns a context object that is a reference to the current context. The current context is the context that contains the monitor instance or event instance that is calling this method.
getId() — Returns an integer that is the ID of the context.
getName() — Returns a string that is the name of the context.
isPublic() — Returns a Boolean that indicates whether the context is public. If the context was created as a public context then the return value is true.
toString() — Returns a string that contains the properties of the context. For example, for a public context whose name is
test, the content of the returned string would be something like this:
context(1, “test”, true)
In addition, the current() static method returns a reference to the current context.