Apama Documentation : Developing Apama Applications : EPL Reference : Types : Reference types : Channel
Channel
Values of the Channel type are objects that hold either a string, which is a channel name, or a context object depending on how you construct it.
Usage
The Channel type is defined in the com.apama namespace. Typically, to easily refer to Channel objects, you specify:
using com.apama.Channel
The Channel type lets you send an event to a channel or context. If the Channel object contains a string then the event is sent to the channel with that name. If the Channel object contains a context then the event is sent to that context.
A Channel object has three constructors:
Channel(string)
Channel(context)
new Channel
The third constructor creates a Channel object that contains an empty context object. The contained empty context is the same result you would get from new context. It is a runtime error to send an event to an empty context. Likewise, it is a runtime error to send an event to a Channel object that contains an empty context.
For example, the following two lines have the same result:
send e to "MyChannel";
send e to Channel("MyChannel");
Similarly, the following two lines have the same result when c is a variable of the context type:
send e to c;
send e to Channel(c);
The benefit of using a Channel object rather than a string or context object is that the Channel object is polymorphic. For example, by using a Channel object to represent the source of a request, you could write a service monitor so that the same code sends a response to a service request. You would not need to have code for sending responses to channels and separate code for sending responses to contexts.
You cannot send an event to a sequence of Channel objects. You cannot route a Channel object, but a routable object can have a Channel object as a member.
Methods
The following methods may be called on values of Channel type:
*canParse(string)Returns true if the string argument can be successfully parsed to create a Channel object. You cannot parse a string representation of a Channel object that contains a context. For more information about the parseable type property, see the table in Type properties summary.
*clone()Returns a new channel that is an exact copy of the channel that this method is called on. The original content of the channel is copied into the new channel.
*empty()Returns true if the Channel object contains an empty context. This lets you distinguish between an object that contains a default initialization value and an object that has been explicitly populated.
*parse(string)Returns the Channel instance represented by the string argument. You can call this method on the Channel type or on an instance of a Channel type. The more typical use is to call parse() directly on the Channel type.
The parse() method takes a single string as its argument. This string must be the string form of a Channel object. The string must adhere to the format described in Event file format. For example:
Channel a;
a := Channel.parse(com.apama.Channel("channelName");
Channel b;
b := Channel.parse(com.apama.Channel(context(3, "contextName", true) );
You can specify the parse() method after an expression or type name. If the correlator is unable to parse the string, it is a runtime error and the monitor instance that the EPL is running in terminates.
*toString()Returns a string that contains the channel name or the name of the contained context.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback