Listener
Class
Superclasses
System.Object
Listener
Visual Basic
Public Class Listener
C#
public class Listener
Purpose
Remarks
Each Listener object represents your program’s interest in a set of message events. When a matching message arrives, TIBCO Rendezvous places the message in the listener’s queue. Dispatch removes the first message from the queue, and raises a MessageReceived event. .NET calls the event handler delegates associated with the listener to process the message.
A listener object continues listening for messages until the program destroys it. The method Listener.Destroy destroys a listener explicitly, immediately canceling interest in messages. You can also destroy a listener implicitly by deleting all references to it, but the garbage collector might introduce a delay before it destroys the object and cancels interest.
Destroying the queue or transport of an listener automatically invalidates the listener as well.
Method |
Description |
Page |
Constructor |
||
Activation and Dispatch
Inbound messages on the transport that match the subject trigger the listener; dispatch raises a MessageReceived event.
The constructor creates a listener object, and activates the event—that is, it begins listening for all inbound messages with matching subjects. When a message arrives, Rendezvous software places the message on the listener’s event queue. Dispatch removes the message from the queue, and raises a MessageReceived event; .NET runs the handler delegates to process the message. (To stop receiving inbound messages on the subject, destroy the listener object; this action cancels all messages already queued for the listener; see also Listener.Destroy.)
Listener Activation and Dispatch illustrates that messages can continue to accumulate in the queue, even while a handler delegate callback function is processing.
Figure 248: Listener Activation and Dispatch
When the callback method is I/O-bound, messages can arrive faster than the callback delegate can process them, and the queue can grow unacceptably long. In programs where a delay in processing messages is unacceptable, consider dispatching from several threads to process messages concurrently.