|
|||||
|
|
|||||
Protocol
Stomp Protocol Specification, Version 1.0Initially the client must open a socket (I'm going to presume TCP, but really it is kind of irrelevant). The client then sends: CONNECT login: <username> passcode:<passcode> ^@
After the client sends the CONNECT frame, the server will always acknowledge the connection, by sending a frame which looks like: CONNECTED session: <session-id> ^@
At this point there are a number of commands the client may send
Client CommandsSENDThe SEND command sends a message to a destination in the messaging system. It has one required header, destination, which indicates where to send the message. The body of the SEND command is the message to be sent. For example: SEND destination:/queue/a hello queue a ^@
SEND supports a transaction header which allows for transaction sends. It is recommended that SEND frames include a content-length header which is a byte count for the length of the message body. If a content-length header is included, this number of bytes should be read, regardless of whether or not there are null characters in the body. The frame still needs to be terminated with a null byte and if a content-length is not specified, the first null byte encountered signals the end of the frame. SUBSCRIBEThe SUBSCRIBE command is used to register to listen to a given destination. Like the SEND command, the SUBSCRIBE command requires a destination header indicating which destination to subscribe to. Any messages received on the subscription will henceforth be delivered as MESSAGE frames from the server to the client. The ack header is optional, and defaults to auto. SUBSCRIBE destination: /queue/foo ack: client ^@
The body of the SUBSCRIBE command is ignored. Stomp brokers may support the selector header which allows you to specify an SQL 92 selector on the message headers which acts as a filter for content based routing. You can also specify an id header which can then later on be used to UNSUBSCRIBE from the specific subscription as you may end up with overlapping subscriptions using selectors with the same destination. If an id header is supplied then Stomp brokers should append a subscription header to any MESSAGE commands which are sent to the client so that the client knows which subscription the message relates to. If using Wildcards and selectors this can help clients figure out what subscription caused the message to be created. UNSUBSCRIBEThe UNSUBSCRIBE command is used to remove an existing subscription - to no longer receive messages from that destination. It requires either a destination header or an id header (if the previous SUBSCRIBE operation passed an id value). Example: UNSUBSCRIBE destination: /queue/a ^@
BEGINBEGIN is used to start a transaction. Transactions in this case apply to sending and acknowledging - any messages sent or acknowledged during a transaction will be handled atomically based on the transaction. BEGIN transaction: <transaction-identifier> ^@
COMMITCOMMIT is used to commit a transaction in progress. COMMIT transaction: <transaction-identifier> ^@
ACKACK is used to acknowledge consumption of a message from a subscription using client acknowledgment. When a client has issued a SUBSCRIBE frame with the ack header set to client any messages received from that destination will not be considered to have been consumed (by the server) until the message has been acknowledged via an ACK. ACK has one required header, message-id, which must contain a value matching the message-id for the MESSAGE being acknowledged. Additionally, a transaction header may be specified, indicating that the message acknowledgment should be part of the named transaction. ACK message-id: <message-identifier> transaction: <transaction-identifier> ^@
Standard HeadersSome headers may be used, and have special meaning, with most packets ReceiptAny client frame other than CONNECT may specify a receipt header with an arbitrary value. This will cause the server to acknowledge receipt of the frame with a RECEIPT frame which contains the value of this header as the value of the receipt-id header in the RECEIPT packet. SEND destination:/queue/a receipt:message-12345 Hello a!^@
Server FramesThe server will, on occasion, send frames to the client (in additional to the initial CONNECTED frame). These frames may be one of:
MESSAGEMESSAGE frames are used to convey messages from subscriptions to the client. The MESSAGE frame will include a header, destination, indicating the destination the message was delivered to. It will also contain a message-id header with a unique identifier for that message. The frame body contains the contents of the message: MESSAGE destination:/queue/a message-id: <message-identifier> hello queue a^@
It is recommended that MESSAGE frames include a content-length header which is a byte count for the length of the message body. If a content-length header is included, this number of bytes should be read, regardless of whether or not there are null characters in the body. The frame still needs to be terminated with a null byte, and if a content-length is not specified the first null byte encountered signals the end of the frame. RECEIPTReceipts are issued from the server when the client has requested a receipt for a given command. A RECEIPT frame will include the header receipt-id, where the value is the value of the receipt header in the frame which this is a receipt for. RECEIPT receipt-id:message-12345 ^@
ERRORThe server may send ERROR frames if something goes wrong. The error frame should contain a message header with a short description of the error, and the body may contain more detailed information (or may be empty). ERROR message: malformed packet received The message: ----- MESSAGE destined:/queue/a Hello queue a! ----- Did not contain a destination header, which is required for message propagation. ^@
This spec is licensed under the Creative Commons Attribution v2.5 |
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||