The C++ broker uses handler chains to break complex processing into individual pieces.

  • Each session has its own set of FrameHandler chains.
  • Frames from the network are delivered to the first handler in the chain.
  • Handlers do something with a frame, then pass it to the next handler.
  • Handlers may "filter" frames by not passing some frames to the next handler.

Current status (2002/9/20)

Each chain starts with a SessionHandler. It handles L2 (session open, close etc.) and passes other frames to the next handler.

L3/L4 frames are handled by the SemanticHandler.

For clustering, a ClusterHandler is inserted at the start of the chain. It replicates frames to a backup broker so the backup can handle failover. It then passes frames on to the normal session handlers.

Approach for multi-frame segments

  • The frame handler chain continues to handle individual frames.
  • Each handler uses a FrameSet to accumulate its frames.
  • Frame no longer contains a Body, moved to FrameSet
    class FrameSet { // sketch
     void add(const Frame& frame); // True if 
     const AMQMethodBody* getMethod(); // 0 means not complete.
     const AMQHeaderBody* getHeader();
     const AMQContentBody* getContent(); 
    };
    
    Note: All the visitor/dispatch classes using AMQFrame need to be reworked. Dispatch will always be based on an AMQMethodBody, not a frame.

Rationale:

''Frame rather than Segment/FrameSet handlers'': Allows most flexibility to compose or not compose frames into segments & FrameSets. For example a cluster handler needs to replicate frame-by-frame, so we don't want to compose the full segment up front. Since the FrameSet class provides the composition logic, this is specified only once and easy to use in frame handlers.

''No Segment class'': A segment by itself is not very useful. A non-content method is just a FrameSet containing a single method segment. For content bearing methods are a frameset with headers & content. There's little value for a stand alone segment class.

  • No labels