Developing Apama Applications > Developing Apama Applications in EPL > Implementing Parallel Processing > Using channels to communicate between contexts
Using channels to communicate between contexts
Contexts can subscribe to channels, using the monitor.subscribe(channelName) operation. When a monitor executes monitor.subscribe(channelName), it causes the context it is running in to be subscribed to that channel. The subscription's lifetime is tied to the lifetime of the monitor instance that executes subscribe(). The subscription is active until that monitor instance terminates or executes monitor.unsubscribe(channelName).
Subscriptions are reference counted. That is, if one monitor instance subscribes twice to the same channel then it needs to unsubscribe twice from that channel. If two monitor instances each subscribe once to the same channel then the subscription is active while either monitor instance exists or until both monitor instances unsubscribe from that channel.
When a context is subscribed to a channel it receives all events sent on that channel. This includes:
*Events sent to the correlator from
*An IAF adapter
*engine_send
*Another correlator connected with engine_connect and using parallel mode
*Clients
*Universal Messaging
*Events sent from EPL using the send...to command
*Events sent from correlator plug-ins to a specific channel
It does not include events emitted with the emit...to command. Even if the target of an emit...to statement is a channel that the context is subscribed to, an event sent by the emit statement goes only to external receivers and not to any contexts.
By using a channel for each stream of data an application may be interested in, an application can control which streams of data it receives through execution of the appropriate monitor.subscribe(channelName) and monitor.unsubscribe(channelName) commands. The correlator can efficiently distribute events within the correlator to multiple contexts, plug-ins or receivers subscribed to channels. If further scale-out is required, using channels allows some application components to be deployed to correlator processes running on other hosts, which are connected using the engine_connect correlator utility or Universal Messaging. See Tuning Correlator Performance.
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.