class AbstractConsumer
package feathers.messaging
extends MessageAgent
extended by Consumer
The AbstractConsumer is the base class for both the Consumer and MultiTopicConsumer classes. You use those classes to receive pushed messages from the server.
Constructor
new()
Constructs a Consumer.
function initConsumer():Void
{
var consumer:Consumer = new Consumer();
consumer.destination = "NASDAQ";
consumer.selector = "operation IN ('Bid','Ask')";
consumer.addEventListener(MessageEvent.MESSAGE, messageHandler);
consumer.subscribe();
}
function messageHandler(event:MessageEvent):Void
{
var msg:IMessage = event.message;
var info:Object = msg.body;
trace("-App recieved message: " + msg.toString());
}
Variables
maxFrequency:UInt
Determines the maximum number of messages per second the Consumer wants to receive. A server that understands this value will use it as an input while it determines how fast to send messages to the Consumer. Default is 0 which means Consumer does not have a preference for the message rate. Note that this property should be set before the Consumer subscribes and any changes after Consumer subscription will not have any effect until Consumer unsubscribes and resubscribes.
resubscribeAttempts:Int
The number of resubscribe attempts that the Consumer makes in the event that the destination is unavailable or the connection to the destination fails. A value of -1 enables infinite attempts. A value of zero disables resubscribe attempts.
Resubscribe attempts are made at a constant rate according to the resubscribe interval value. When a resubscribe attempt is made if the underlying channel for the Consumer is not connected or attempting to connect the channel will start a connect attempt. Subsequent Consumer resubscribe attempts that occur while the underlying channel connect attempt is outstanding are effectively ignored until the outstanding channel connect attempt succeeds or fails.
See also:
mx.messaging.Consumer#resubscribeInterval
resubscribeInterval:Int
The number of milliseconds between resubscribe attempts. If a Consumer doesn't receive an acknowledgement for a subscription request, it will wait the specified number of milliseconds before attempting to resubscribe. Setting the value to zero disables resubscriptions.
Resubscribe attempts are made at a constant rate according to this value. When a resubscribe attempt is made if the underlying channel for the Consumer is not connected or attempting to connect the channel will start a connect attempt. Subsequent Consumer resubscribe attempts that occur while the underlying channel connect attempt is outstanding are effectively ignored until the outstanding channel connect attempt succeeds or fails.
Throws:
ArgumentError | If the assigned value is negative. |
---|
See also:
mx.messaging.Consumer#resubscribeInterval
read onlysubscribed:Bool
Indicates whether the Consumer is currently subscribed. The propertyChange
event is dispatched when this property changes.
timestamp:Float
Contains the timestamp of the most recent message this Consumer
has received.
This value is passed to the destination in a receive()
call
to request that it deliver messages for the Consumer from the timestamp
forward.
All messages with a timestamp value greater than the
timestamp
value will be returned during a poll operation.
Setting this value to -1 will retrieve all cached messages from the
destination.
Methods
disconnect():Void
Disconnects the Consumer from its remote destination. This method should be invoked on a Consumer that is no longer needed by an application after unsubscribing. This method does not wait for outstanding network operations to complete and does not send an unsubscribe message to the server. After invoking disconnect(), the Consumer will report that it is in an disconnected, unsubscribed state because it will not receive any more messages until it has reconnected and resubscribed. Disconnecting stops automatic resubscription attempts if they are running.
fault(errMsg:ErrorMessage, msg:IMessage):Void
The Consumer supresses ErrorMessage processing if the error is retryable and it is configured to resubscribe.
Parameters:
errMsg | The ErrorMessage describing the fault. |
---|---|
msg | The original message (generally a subscribe). |
receive(timestamp:Float = 0):Void
Requests any messages that are queued for this Consumer on the server. This method should only be used for Consumers that subscribe over non-realtime, non-polling channels. This method is a no-op if the Consumer is not subscribed.
Parameters:
timestamp | This argument is deprecated and is ignored. |
---|
subscribe(?clientId:String):Void
Subscribes to the remote destination.
Parameters:
clientId | The client id to subscribe with. Use null for non-durable Consumers. If the subscription is durable, a consistent value must be supplied every time the Consumer subscribes in order to reconnect to the correct durable subscription in the remote destination. |
---|
Throws:
mx.messaging.errors.InvalidDestinationError | If no destination is set. |
---|
unsubscribe(preserveDurable:Bool = false):Void
Unsubscribes from the remote destination. In the case of durable JMS subscriptions, this will destroy the durable subscription on the JMS server.
Parameters:
preserveDurable |
|
---|