#524 JMS: Scheduled Messages -- additional features

JBossMQ (39)
Andrew Clute

This patch has one minor bug fix:
+ BasicQueue.clearEvent() was not decrementing the

This patch adds two major new features:
+ Allow the listing of all Scheduled Messages for
Topics and Queues from the JMX Console

+ Allow for Scheduled Messages to be 'viewable' by
receivers when attempting to recieve a message with a

The main purpose is that for use cases where scheduled
messages need to be canceled, a QueueReceiver can
create a selector to pull that message off before it
hits the queue.

To do this, a new attirbute is added to Queues:

Ideally, this flag would be set when a QueueReceiver is
created for pulling this message off -- but the JMS API
has no interface methods that allow the setting of
paramters specific to a receiver.

Thus the new attribute (default to false) allows for
developers to decide if a particular queue should allow
this feature at both deployment time, and runtime via JMX.

Almost all changes are additions to existing methods
with the exception of one thing: In BasicQueue, the
'events' collection that use to be a ConcurrentHashMap
was changed to a ConcurrentReaderHashMap. The need for
this change arose from the potential race-condition
when a scheduled message is found to satisfy the
selector, but is not removed from the events before it
is awoken and delivered to the queue.

ConcurrentReaderHashMap allows for syncronization on
removes, to ensure that a Scheduled message will not be
delievered to the queue until any removes are
processed, and thus allows a check to make sure the
Message is still valid before being delievered.

Thanks for your time! I would appreciate any feedback.


  • Andrew Clute
    Andrew Clute