activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SuoNayi <suonayi2...@163.com>
Subject Re:Discard messages for Slow consumers on "Queue"
Date Tue, 19 Mar 2013 12:15:05 GMT
The policies to discard messages only work for the topic.
For queue you have to specify the expiration time for messages and the broker will periodically
discard expired messages.




At 2013-03-19 14:00:33,jaikit <jktsavla@gmail.com> wrote:
>Hi Docs,
>
>I have running Active MQ 5.8 and have setup VirtualDestinations (2 queues).
>One of the queue is slow and it is not discarding messages. Could some one
>please suggest how should I enable discarding messages for that queue ?
>
>please find below my code snippet:
>
>        broker.setDeleteAllMessagesOnStartup(true);
>        broker.setUseJmx(true);
>        broker.setAdvisorySupport(false);
>        PolicyMap policyMap = new PolicyMap();
>        List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
>        PolicyEntry topicPolicy = new PolicyEntry();
>        topicPolicy.setTopic(">");
>        topicPolicy.setTopicPrefetch(100);
>        // topicPolicy.setProducerFlowControl(false);
>        entries.add(topicPolicy);
>
>        PolicyEntry queuePolicy = new PolicyEntry();
>        // queuePolicy.setProducerFlowControl(false);
>        queuePolicy.setQueue(">");
>
>        queuePolicy.setMemoryLimit(100);
>        ConstantPendingMessageLimitStrategy
>constantPendingMessageLimitStrategy = new
>ConstantPendingMessageLimitStrategy();
>        constantPendingMessageLimitStrategy.setLimit(1);
>
>       
>queuePolicy.setPendingMessageLimitStrategy(constantPendingMessageLimitStrategy);
>        OldestMessageEvictionStrategy oldestMessageEvictionStrategy = new
>OldestMessageEvictionStrategy();
>       
>oldestMessageEvictionStrategy.setEvictExpiredMessagesHighWatermark(1);
>       
>queuePolicy.setMessageEvictionStrategy(oldestMessageEvictionStrategy);
>        /* the period (in ms) of checks for message expiry on queued
>messages, value of 0 disables */
>        queuePolicy.setExpireMessagesPeriod(1000);
>        /* Set the PrefetchSize for all topics. You can override this value
>while creating consumer. */
>        // policy.setTopicPrefetch(10);
>        queuePolicy.setQueuePrefetch(10);
>        entries.add(queuePolicy);
>        policyMap.setPolicyEntries(entries);
>        broker.setDestinationPolicy(policyMap);
>
>        /* All undeliverable messages will be sent to ActiveMQ.DLQ which has
>fixed size. If it reaches fixed size,
>         * producers will be throttled. Drop dead letter queue. Enable it
>case by case basis. */
>        DiscardingDLQBrokerPlugin dlqBrokerPlugin = new
>DiscardingDLQBrokerPlugin();
>        dlqBrokerPlugin.setDropAll(true);
>        dlqBrokerPlugin.setDropTemporaryTopics(true);
>        dlqBrokerPlugin.setDropTemporaryQueues(true);
>        BrokerPlugin[] plugins = { dlqBrokerPlugin };
>        broker.setPlugins(plugins);
>
>        VirtualTopic virtualTopic = new VirtualTopic();
>        // the new config that enables selectors on the intercepter
>        virtualTopic.setSelectorAware(true);
>        VirtualDestinationInterceptor interceptor = new
>VirtualDestinationInterceptor();
>        interceptor.setVirtualDestinations(new VirtualDestination[] {
>virtualTopic });
>        broker.setDestinationInterceptors(new DestinationInterceptor[] {
>interceptor });
>        broker.start();
>
>
>
>--
>View this message in context: http://activemq.2283324.n4.nabble.com/Discard-messages-for-Slow-consumers-on-Queue-tp4664858.html
>Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message