Developing Apama Applications > Developing Apama Applications in EPL > Implementing Parallel Processing > Sending an event to a channel
Sending an event to a channel
In a monitor, you can send an event to a channel by using either
*A string value that identifies the channel name
*A com.apama.Channel type that either names a channel or holds a context reference
The format for sending an event to a particular context is as follows:
send EventExpression to ChannelExpression;
Replace EventExpression with any valid EPL expression that is of an event type.
Replace ChannelExpression with any valid EPL expression that is of the string or com.apama.Channel type. Typically, this is a string value.
This statement asynchronously sends an event to everything subscribed to the specified channel. Subscribers can include
*Contexts
*Receivers connected to external components by means of Apama's messaging, JMS or Universal Messaging
*Correlator plug-ins that have subscribed an EventHandler object
For each target subscribed to a channel, the event goes to the back of the context's input queue.
In a target context, the correlator can immediately process the sent event. The correlator does not need to finish executing the action that sends the event before it processes the sent event in a target context. The correlator might process the sent event before it finishes executing the action that sent the event. Or, the correlator might process the sent event some time after it completes executing the action that sent the event. The order is unpredictable. The order in which the target contexts receive the sent event is also unpredictable. For example:
action analyse(string symbol) {
spawn submon(symbol) to context(symbol);
com.apama.marketdata.Tick tick;
log "Listening for "+symbol;
on all com.apama.marketdata.Tick(symbol=symbol):tick {
send tick to symbol;
}
on com.apama.marketdata.Finished() {
send com.apama.marketdata.Finished() to symbol;
}
}
 
action submon(string symbol) {
monitor.subscribe(symbol);...
}
It is possible for a send...to operation to block the sending context from further processing if the input queue of any target (context, receiver or plug-in) is full. Either an event that you send to a particular target arrives on the target's input queue or the sending context waits for room on the target's input queue.
If you send an event to a channel that has no subscribers, the correlator discards the event because there are no listeners for it. This is not an error.
See also:
*Generating events with the send command
*Working with channels in C++ plug-ins
*Using Java plug-ins
Copyright © 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.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.