Package com.rabbitmq.client.impl.nio
Class FrameBuilder
- java.lang.Object
-
- com.rabbitmq.client.impl.nio.FrameBuilder
-
- Direct Known Subclasses:
SslEngineFrameBuilder
public class FrameBuilder extends java.lang.ObjectClass to create AMQP frames from aReadableByteChannel. Supports partial frames: a frame can be read in several attempts from theNioLoop. This can happen when the channel won't read any more bytes in the middle of a frame building. The state of the outstanding frame is saved up, and the builder will start where it left off when theNioLoopcomes back to this connection. This class is not thread safe.- Since:
- 4.4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.ByteBufferapplicationBufferprivate intbytesReadprotected java.nio.channels.ReadableByteChannelchannelprivate int[]frameBufferprivate intframeChannelprivate byte[]framePayloadprivate intframeTypeprivate intmaxPayloadSizeprivate static intPAYLOAD_OFFSET
-
Constructor Summary
Constructors Constructor Description FrameBuilder(java.nio.channels.ReadableByteChannel channel, java.nio.ByteBuffer buffer, int maxPayloadSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidhandleProtocolVersionMismatch()Handle a protocol version mismatch.booleanisUnderflowHandlingEnabled()FramereadFrame()Read a frame from the network.private intreadFromBuffer()protected booleansomethingToRead()Tells whether there's something to read in the application buffer or not.
-
-
-
Field Detail
-
PAYLOAD_OFFSET
private static final int PAYLOAD_OFFSET
- See Also:
- Constant Field Values
-
channel
protected final java.nio.channels.ReadableByteChannel channel
-
applicationBuffer
protected final java.nio.ByteBuffer applicationBuffer
-
maxPayloadSize
private final int maxPayloadSize
-
frameBuffer
private final int[] frameBuffer
-
frameType
private int frameType
-
frameChannel
private int frameChannel
-
framePayload
private byte[] framePayload
-
bytesRead
private int bytesRead
-
-
Method Detail
-
readFrame
public Frame readFrame() throws java.io.IOException
Read a frame from the network. This method returns null f a frame could not have been fully built from the network. The client must then retry later (typically when the channel notifies it has something to read).- Returns:
- a complete frame or null if a frame couldn't have been fully built
- Throws:
java.io.IOException- See Also:
Frame.readFrom(DataInputStream, int)
-
somethingToRead
protected boolean somethingToRead() throws java.io.IOExceptionTells whether there's something to read in the application buffer or not. Tries to read from the network if necessary.- Returns:
- true if there's something to read in the application buffer
- Throws:
java.io.IOException
-
readFromBuffer
private int readFromBuffer()
-
handleProtocolVersionMismatch
private void handleProtocolVersionMismatch() throws java.io.IOExceptionHandle a protocol version mismatch.- Throws:
java.io.IOException- See Also:
Frame.protocolVersionMismatch(DataInputStream)
-
isUnderflowHandlingEnabled
public boolean isUnderflowHandlingEnabled()
-
-