Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 7. Message Prefetch Behavior
Overview Copier lienLien copié sur presse-papiers!
Figure 7.1. Consumer Prefetch Limit
Consumer specific prefetch limits Copier lienLien copié sur presse-papiers!
| Consumer Type | Property | Default |
|---|---|---|
| Queue consumer | queuePrefetch | 1000 |
| Queue browser | queueBrowserPrefetch | 500 |
| Topic consumer | topicPrefetch | 32766 |
| Durable topic subscriber | durableTopicPrefetch | 100 |
Setting prefetch limits per broker Copier lienLien copié sur presse-papiers!
destinationPolicy element as a child of the broker element in the broker's configuration, as shown in Example 7.1, “Configuring a Destination Policy”.
Example 7.1. Configuring a Destination Policy
<broker ... >
...
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue="queue.>" queuePrefetch=”1”/>
<policyEntry topic="topic.>" topicPrefetch=”1000”/>
</policyEntries>
</policyMap>
</destinationPolicy>
...
</broker>
queue. is set to 1 (the > character is a wildcard symbol that matches one or more name segments); and the topic prefetch limit for all topics whose names start with topic. is set to 1000.
Setting prefetch limits per connection Copier lienLien copié sur presse-papiers!
ActiveMQConnectionFactory instance. Example 7.2, “Setting Prefetch Limit Properties Per Connection” shows how to specify the prefetch limits for all consumer types on a connection factory.
Example 7.2. Setting Prefetch Limit Properties Per Connection
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
Properties props = new Properties();
props.setProperty("prefetchPolicy.queuePrefetch", "1000");
props.setProperty("prefetchPolicy.queueBrowserPrefetch", "500");
props.setProperty("prefetchPolicy.durableTopicPrefetch", "100");
props.setProperty("prefetchPolicy.topicPrefetch", "32766");
factory.setProperties(props);
Setting prefetch limits per destination Copier lienLien copié sur presse-papiers!
TEST.QUEUE with a prefetch limit of 10. The option is set as a destination option as part of the URI used to create the queue.
Example 7.3. Setting the Prefect Limit on a Destination
Queue queue = new ActiveMQQueue("TEST.QUEUE?consumer.prefetchSize=10");
MessageConsumer consumer = session.createConsumer(queue);
Disabling the prefetch extension logic Copier lienLien copié sur presse-papiers!
Example 7.4. Disabling the Prefetch Extension
<broker ... >
...
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" usePrefetchExtension=”false”/>
</policyEntries>
</policyMap>
</destinationPolicy>
...
</broker>