wso2-dev/andes — pull request #142 by hastef88 (2014-11-11 09:44:20+00:00)
Title: Queue Purge Feature to support removing all messages not awaiting acknowledgement on a given queue.

Rationale :
---------------

According to AMQP spec 0_9_1 : Once purged, We need to remove all messages which are not awaiting acknowledgement from the given queue.

Requirements in terms of MB 3.0.0 architecture :
---------------------------------------------------------------------------

Once a queue purge is requested from UI console (queue->browse page), all messages addressed to that queue in the receiving node in memory should be cleared.

If in a cluster, all other nodes should be notified of the purge event including the timestamp, after which those nodes must clear their in memory messages of the given queue.

All messages in delivery threads will be skipped if their arrival Time is before the purged timestamp.

All messages of the queue in durable store should be removed (JDBC / Cassandra)

Any message counters for the queue in store should be reset to 0.

*Messages published to that queue immediately after a purge should still be received by the subscriber later.

Other fixes done when testing :
---------------------------------------------

Handled NoSuchElementException in QueueDeliveryWorker : sendMessagesToSubscribers.

Handled NPE in OnFlightMessageTracker : releaseAllMessagesOfSlotFromTracking.

Descriptive exception handling for message delivery failures in SubscriptionImpl.

Added controlled thread sleeps to better handle threadpool exhaustion at QueueDeliveryWorker : sendMessageToFlusher