Apama 10.3.1 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining What Happens When Matching Events Are Found | Generating events | Generating events with the send statement
 
Generating events with the send statement
The send statement sends an event to a channel, a context, a sequence of contexts, or a com.apama.Channel object.
When you send an event to a channel, the correlator delivers it to all contexts and external receivers that are subscribed to that channel. To send an event, use the following format:
send event_expression to expression;
The result type of event_expression must be an event. It cannot be a string representation of an event. The send statement can operate on any values as well as events, provided that the any value is of a routable event type.
To send an event to a channel, the expression must resolve to a string or a com.apama.Channel object that contains a string. If there are no contexts and no external receivers that are subscribed to the specified channel, then the event is discarded. See Subscribing to channels.
The only exception to this is the default channel, which is the empty string. Events sent to the default channel go to all public contexts. All running Apama queries receive events sent on the default channel as well as events sent on the com.apama.queries channel. See Defining Queries.
To send an event to a context, the expression must resolve to a context, a sequence of contexts, or a com.apama.Channel object that contains a context. You must create a context before you send an event to the context. You cannot send 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()
   {
      send A() to c;
   }
}
If you send an event to a sequence of contexts and one of the contexts has not been created first, then the correlator terminates the monitor instance. Sending an event to a sequence of contexts is non-deterministic. You cannot send an event to a sequence of com.apama.Channel objects. For details, see Sending an event to a sequence of contexts.
All routable event types can be sent to contexts, including event types defined in monitors. There is a runtime check if the event (or one of its members) can contain an any field; an exception is thrown if the any field contains an object of type action, chunk, listener, or stream.
If a correlator is configured to connect to Universal Messaging, then a channel might have a corresponding Universal Messaging channel. If there is a corresponding Universal Messaging channel, then Universal Messaging is used to send the event to that Universal Messaging channel.
See Choosing when to use Universal Messaging channels and when to use Apama channels.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.