Responsibilities

(correct as of 2014-12-03).

 We want to refactor the queue / message delivery model within the Java Broker.  The current code has evolved overtime and the division of responsibilities is poor. This makes the code difficult to reason about and makes writing good unit tests hard.

In order to support this effort I have written down all the responsibilities of the classes involved in queues / message delivery.

Virtualhost

  • Housekeeper responsible for requesting that queues:
    • expire messages whose TTL has been reached
    • flow messages to disk if memory usage is high

QueueImpls

These are the queue implementation objects eg. StandardQueue, LVQQueue etc.  These are model objects. 

 

  • Accepts ConsumerTarget from ProtocolLayers and creates QueueConsumers
  • Maintains a list of QueueConsumers
  • Enqueuing of queue entries
  • Delivery/dequeue of queue entries
    • Straight-through path (from enqueue) pushing messages onto wire
    • Basic.get pushing messages
    • QR/SFR pushing messages onto the wire
  • Asks  the QueueConsumer if the message is interesting to the consumer (JMS filter etc)
  • Asks the QueueConsumer (or consumer’s session) if there is sufficient credit for a message
    • Refunds credit if for some reason the send could not be completed (for instance something else has acquired the message)
  • Fairness - round robins the queue entries amongst the consumers
    • Each processQueue iteration takes up to 80 messages and distributes them roughly equally amongst the consumers.
  • Assigning messages to groups
  • Expiring TTLd messages and flow messages to disk
  • Enforcing queue capacities and exerting back pressure back to producer sessions.

ConsumerTarget 

(These are a protocol specific representation of a Consumer.  They are not model objects).

 

  • There are protocol layer specific implementations of consumer targets
  • Created by the protocol layers.   ProtocolLayer keep a handle on the ConsumerTargets
  • Accepts a filter manager
  • Accepts a credit manager
  • Asks credit manager for credit for queue entry
  • Asks credit manager to restore credit
  • Sends messages to the client
  • Tracks unacknowledged messages

QueueConsumers  

(These are model objects (they extend Consumer).  They represent the Consumers themselves.

  • Created by the Queues.  In essence wraps a ConsumerTarget
  • Some QueueConsumers are acquiring, some not (i.e. browsers)
  • Asks consumer target for credit for queue entry
  • Asks  consumer target to restore credit
  • Accepts a requests to send the message - delegates to the target
  • Uses MessageConnverters
  • Decides if a queue entry is interesting to a consumer
    • If a message has been rejected
    • No local
    • Filters
    • Message Conversion

CreditManager

 (Manage credit)

  • Created by the ProtocolLayers
  • state fully manages credit and suspended status

FilterManager

 (Implement filtering such as JMS message selectors).

  • Created by the ProtocolLayers

 

 

 

 

 

  • No labels