hornetq/hornetq — pull request #891 by gaohoward (2013-02-28 12:15:25+00:00)
Title: HQ1104 STOMP 1.2 support

Implementation of STOMP version 1.2 support in HornetQ

Here is the STOMP V1.2 spec.
http://stomp.github.com/stomp-specification-1.2.html

STOMP v1.2 doesn't have much difference from v1.1. So it could be easily added to HornetQ based on the current code base with the following changes:

1. Refactor existing STOMP 1.0/1.1 code to improve code reusability.
2. Add the few new features mainly stated in the spec (see section 'Changes in the Protocol').
3. add an simple example
4. document update
5. tests

Below are details of general Stomp request processing

All incoming/outgoing bytes from/to a stomp client are processed by StompProtocolManager class. The StompProtocolManager creates a StompConnection for each client connection request.

Stomp version for each connection is determined during connection time, and so is the authentication.

Once connected, a StompConnection has a VersionedStompFrameHandler initiated. The VersionedStompFrameHandler has mainly two tasks:

task 1 : it uses a version specific decoder to decode stomp bytes into StompFrames
task 2 : it processes the decoded StompFrames and sends responses to client if needed.

Here is a summary of the VersionedStompFrameHandlers/decoders for each version

Stomp 1.0: StompFrameHandlerV10/StompDecoder
Stomp 1.1: StompFrameHandlerV11/StompDecoderV11
Stomp 1.2: StompFrameHandlerV12/StompDecoderV12

Here classes of higher versions usually inherits those of lower versions to maximize code reuse.

Message requests are converted into HornetQ core semantics and actually processed by the core layer. Internally we have a StompSession to wrap a core session to do the work. It can be shown briefly using the following flow:

=(incoming bytes)==>StompProtocolManager==>StompConnection==>StompDecoder == (Stomp frames) ==> FrameHandler ==>StompSession ==> Core

Messages are sent to client in the following flow:

Core ==(core message)==>StompSession==>FrameHandler==(stomp frames)==>StompProtocolManager==>StompConnection===(physical network)==>client

Testing

We have a simple testing client to simulate STOMP clients. Related tests are in the following classes:

StompTest
ExtraStompTest
StompV11Test
StomeV12Test