Apama 10.3 | Apama Documentation | 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
*Another correlator connected with engine_connect and using parallel mode
*Universal Messaging
*Events sent from EPL using the send...to statement
*Events sent from EPL plug-ins to a specific channel
It does not include events emitted with the emit...to statement. 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) operations. 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 tool or Universal Messaging. See Tuning Correlator Performance.

Copyright © 2013-2018 | 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.