The maxFrequency property of a client-side
Consumer, MultiTopicConsumer, or DataService component lets you
limit the number of messages the component receives from a destination.
The server read this information and ensures that it limits the
messages it sends to the maximum number of messages per second specified.
The server sends up to the limit, but can send fewer messages depending
on how many messages are available on the server to send. The maxFrequency property
is set when the Consumer, MutiTopicConsumer, or DataService component
subscribes.
The following example sets the maxFrequency property
of a Consumer component that you create in ActionScript:
...
<mx:Script>
<![CDATA[
var consumer:Consumer = new Consumer();
consumer.destination = "chat";
consumer.maxFrequency = 40;
consumer.subscribe();
]]>
</mx:Script>
...
You can also set the maxFrequency property of
a Consumer, MultiTopicConsumer, or DataService component that you
create in MXML as the following example shows:
...
<mx:Consumer id="consumer" destination="chat" maxFrequency="40"/>
...
MultiTopicConsumer message frequency
Unlike
the standard Consumer component, the MultiTopicConsumer component
supports multiple subscriptions. You can set a default value for
the maxFrequency property of a MultiTopicConsumer
component, and also set separate values for individual subscriptions.
The following example shows a MultiTopicConsumer with a default maxFrequency value
of 40 messages per second. One of its two subscriptions uses the
default value, while the other uses a different maxFrequency value
specified in the third parameter of the addSubscription() method.
The first two parameters of the addSubscription() method
specify the subtopic and selector, respectively. The selector value
is null in this case.
...
<mx:Script>
<![CDATA[
var consumer:MultiTopicConsumer = new MultiTopicConsumer();
...
consumer.maxFrequency = 40;
// For this subscription, use the default maxFrequency of 40.
consumer.addSubscription("chat.subtopic1");
// Only for this subscription, overwrite the maxFrequency to 20.
consumer.addSubscription("chat.subtopic2", null, 20);
consumer.subscribe();
]]>
</mx:Script>
...
For more information about the MultiTopicConsumer
component, see Multitopic producers and consumers.
DataService message frequency
For the
DataService component, you specify the default value of the maxFrequency property
as the following example shows:
...
<mx:Script>
<![CDATA[
...
var ds:DataService = new DataService("Meeting");
ds.maxFrequency = 20;
...
]]>
</mx:Script>
...
When you use a DataService component in manual
routing mode (manual synchronization of messages), you can specify
multiple subscriptions and subscription-level values for the maxFrequency property
as the following example shows. As with the MultiTopicConsumer.addSubscription() method,
the manualSync.consumerAdSubscription() method
takes subtopic, selector, and maxFrequency in its three parameters.
...
<mx:Script>
<![CDATA[
...
var ds:DataService = new DataService("Meeting");
ds.autoSyncEnabled = false;
ds.manualSync.producerSubtopics.addItem("flex-room");
// Set the subscription level frequency to 10.
ds.manualSync.consumerAddSubscription("flex-room", null, 10);
ds.manualSync.consumerSubscribe();
ds.fill(…);
...
]]>
</mx:Script>
...
For more information about manual routing, see Manually routing data messages.