Developing Apama Applications > Developing Apama Applications in EPL > Defining What Happens When Matching Events Are Found > Generating events > Enqueuing to contexts
Enqueuing to contexts
To enqueue an event to a particular context, use the following form of the enqueue statement:
enqueue event_expression to context_expression;
The result type of event_expression must be event. It cannot be a string representation of an event.
Even if you have a single context, a call to enqueue x to context.current() is meaningful and useful.
You must create the context before you enqueue an event to the context. You cannot enqueue an event to a context that you have declared but not created. For example, the following code causes the correlator to terminate the monitor instance:
monitor m {
   context c;
   action onload()
   {
      enqueue A() to c;
   }
}
If you enqueue an event to a sequence of contexts and one of the contexts has not been created first then the correlator terminates the monitor instance. For details, see Enqueuing an event to a particular context in Developing Apama Applications in EPL.
Enqueueing an event to a sequence of contexts is non-deterministic. For details, see Enqueuing an event to a sequence of contexts in Developing Apama Applications in EPL.
All routable event types can be enqueued to contexts, including event types defined in monitors.
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.