The emit statement
The emit statement publishes an event to a named channel of the correlator's output queue. If a channel name is not specified, then the event goes to the default channel whose name is the empty string ( ""). External receivers get events on the default channel only if they are subscribed to all channels.
Note:
The
emit statement will be deprecated in a future release. Use the
send statement instead. See
The send . . . to statement.
The first expression is an expression whose result type is either an event type or string. If the type is string, then the value of the string is assumed to be in the same format as that produced by the event's toString() method.
The expression following the keyword to must be of type string and is the name of the channel to which the event will be sent.
The emit method dispatches events to external registered event receivers. That is, the emit statement causes events to go out of the correlator. Active event listeners will not receive events that are emitted.
Events are emitted onto named channels. For an application to receive events from the correlator it must register itself as an event receiver and subscribe to one or more channels. Then if events are emitted to those channels they will be forwarded to it.
Channels effectively allow both point-to-point message delivery as well as through publish-subscribe. Channels can be set up to represent topics. External applications can then subscribe to event messages of the relevant topics. Otherwise a channel can be set up purely to indicate a destination and have only one application connected to it.
You cannot emit an event whose type is defined inside a monitor.
The emit statement can operate on any values as well as events, provided that the any value is of a routable event type.
You cannot emit an event that has a field of type action, chunk, listener, or stream. 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.
When you emit an event type that has a dictionary field, the items in the dictionary are sorted in ascending order of their key values.