Class StompDecoder
ByteBuffer
.
An attempt is made to read all complete STOMP frames from the buffer, which could be zero, one, or more. If there is any left-over content, i.e. an incomplete STOMP frame, at the end the buffer is reset to point to the beginning of the partial content. The caller is then responsible for dealing with that incomplete content by buffering until there is more input available.
- Since:
- 4.0
- Author:
- Andy Wilkinson, Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(ByteBuffer byteBuffer) Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessages
.decode
(ByteBuffer byteBuffer, MultiValueMap<String, String> partialMessageHeaders) Decodes one or more STOMP frames from the givenbuffer
and returns a list ofMessages
.Return the configuredMessageHeaderInitializer
, if any.void
setHeaderInitializer
(MessageHeaderInitializer headerInitializer) Configure aMessageHeaderInitializer
to apply to the headers ofMessages
from decoded STOMP frames.protected void
skipEol
(ByteBuffer byteBuffer) Skip one ore more EOL characters at the start of the given ByteBuffer.
-
Constructor Details
-
StompDecoder
public StompDecoder()
-
-
Method Details
-
setHeaderInitializer
Configure aMessageHeaderInitializer
to apply to the headers ofMessages
from decoded STOMP frames. -
getHeaderInitializer
Return the configuredMessageHeaderInitializer
, if any. -
decode
Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessages
. If the input buffer contains partial STOMP frame content, or additional content with a partial STOMP frame, the buffer is reset, and an empty list is returned.- Parameters:
byteBuffer
- the buffer to decode the STOMP frame from- Returns:
- the decoded messages, or an empty list if none
- Throws:
StompConversionException
- in case of decoding issues
-
decode
public List<Message<byte[]>> decode(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> partialMessageHeaders) Decodes one or more STOMP frames from the givenbuffer
and returns a list ofMessages
.If the given ByteBuffer contains only partial STOMP frame content and no complete STOMP frames, an empty list is returned, and the buffer is reset to where it was.
If the buffer contains one or more STOMP frames, those are returned, and the buffer is reset to point to the beginning of the unused partial content.
The
partialMessageHeaders
map is used to store successfully parsed headers in case of partial content. The caller can then check if a "content-length" header was read, which helps to determine how much more content is needed before the next attempt to decode.- Parameters:
byteBuffer
- the buffer to decode the STOMP frame frompartialMessageHeaders
- an empty output map that will store the last successfully parsed partial message headers in case of partial message content in cases where the partial buffer ended with a partial STOMP frame- Returns:
- the decoded messages, or an empty list if none
- Throws:
StompConversionException
- in case of decoding issues
-
skipEol
Skip one ore more EOL characters at the start of the given ByteBuffer. STOMP, section 2.1 says: "The NULL octet can be optionally followed by multiple EOLs."
-