Package com.rabbitmq.client.impl
Class CommandAssembler
java.lang.Object
com.rabbitmq.client.impl.CommandAssembler
Class responsible for piecing together a command from a series of
This class is thread-safe, since all methods are synchronised. Callers should not synchronise on objects of this class unless they are sole owners.
Frame
s.
ConcurrencyThis class is thread-safe, since all methods are synchronised. Callers should not synchronise on objects of this class unless they are sole owners.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
Current state, used to decide how to handle each incoming frame. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
sum of the lengths of all fragmentsprivate final List
<byte[]> The fragments of this command's content body - a list of byte[]private AMQContentHeader
The content header for this commandprivate static final byte[]
private final int
private Method
The method for this commandprivate long
No bytes of content body not yet accumulatedprivate CommandAssembler.CAState
-
Constructor Summary
ConstructorsConstructorDescriptionCommandAssembler
(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendBodyFragment
(byte[] fragment) private byte[]
Stitches together a fragmented content body into a single byte arrayprivate void
private void
private void
byte[]
boolean
handleFrame
(Frame f) boolean
private void
Decides whether more body frames are expected
-
Field Details
-
EMPTY_BYTE_ARRAY
private static final byte[] EMPTY_BYTE_ARRAY -
state
-
method
The method for this command -
contentHeader
The content header for this command -
bodyN
The fragments of this command's content body - a list of byte[] -
bodyLength
private int bodyLengthsum of the lengths of all fragments -
remainingBodyBytes
private long remainingBodyBytesNo bytes of content body not yet accumulated -
maxBodyLength
private final int maxBodyLength
-
-
Constructor Details
-
CommandAssembler
public CommandAssembler(Method method, AMQContentHeader contentHeader, byte[] body, int maxBodyLength)
-
-
Method Details
-
getMethod
-
getContentHeader
-
isComplete
public boolean isComplete()- Returns:
- true if the command is complete
-
updateContentBodyState
private void updateContentBodyState()Decides whether more body frames are expected -
consumeMethodFrame
- Throws:
IOException
-
consumeHeaderFrame
- Throws:
IOException
-
consumeBodyFrame
-
coalesceContentBody
private byte[] coalesceContentBody()Stitches together a fragmented content body into a single byte array -
getContentBody
public byte[] getContentBody() -
appendBodyFragment
private void appendBodyFragment(byte[] fragment) -
handleFrame
- Parameters:
f
- frame to be incorporated- Returns:
- true if command becomes complete
- Throws:
IOException
- if error reading frame
-