/** * @return */ private int remainingBytes() { return bb.writerIndex() - bb.readerIndex(); }
@Override public void open() { getBodyBuffer().readerIndex(0); }
public static byte streamReadByte(ActiveMQBuffer buff) { int index = buff.readerIndex(); try { byte type = buff.readByte(); switch (type) { case DataConstants.BYTE: return buff.readByte(); case DataConstants.STRING: String s = buff.readNullableString(); return Byte.parseByte(s); default: throw new IllegalStateException("Invalid conversion"); } } catch (NumberFormatException e) { buff.readerIndex(index); throw e; } }
@Override public void decode(final ActiveMQBuffer buffer) { channelID = buffer.readLong(); decodeRest(buffer); size = buffer.readerIndex(); }
/** * @param sendBlocking * @param msgI * @param handler * @throws ActiveMQException */ private void largeMessageSendBuffered(final boolean sendBlocking, final ICoreMessage msgI, final ClientProducerCredits credits, SendAcknowledgementHandler handler) throws ActiveMQException { msgI.getBodyBuffer().readerIndex(0); largeMessageSendStreamed(sendBlocking, msgI, new ActiveMQBufferInputStream(msgI.getBodyBuffer()), credits, handler); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part ByteBuf messageBuffer = copyMessageBuffer(buffer.byteBuf(), 1); receiveMessage(messageBuffer); buffer.readerIndex(buffer.capacity() - 1); requiresResponse = buffer.readBoolean(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part receiveMessage(copyMessageBuffer(buffer.byteBuf(), DataConstants.SIZE_LONG + DataConstants.SIZE_INT)); buffer.readerIndex(buffer.capacity() - DataConstants.SIZE_LONG - DataConstants.SIZE_INT); this.consumerID = buffer.readLong(); this.deliveryCount = buffer.readInt(); }
int bytesToRead = qbuff.writerIndex() - qbuff.readerIndex(); final byte[] body = ByteUtil.getActiveArray(qbuff.readBytes(bytesToRead).toByteBuffer());
@Override public void decode(ActiveMQBuffer buffer) { int original = buffer.readerIndex(); try { decode(buffer, false); } catch (Throwable e) { buffer.readerIndex(original); // Try a compatible version where the wire was broken decode(buffer, true); } }
/** * @return */ private int remainingBytes() { return bb.writerIndex() - bb.readerIndex(); }
/** * @return */ private int remainingBytes() { return bb.writerIndex() - bb.readerIndex(); }
@Override public void decode(final ActiveMQBuffer buffer) { channelID = buffer.readLong(); decodeRest(buffer); size = buffer.readerIndex(); }
@Override public void decode(final ActiveMQBuffer buffer) { channelID = buffer.readLong(); decodeRest(buffer); size = buffer.readerIndex(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part receiveMessage(copyMessageBuffer(buffer.byteBuf(), DataConstants.SIZE_LONG + DataConstants.SIZE_INT)); buffer.readerIndex(buffer.capacity() - DataConstants.SIZE_LONG - DataConstants.SIZE_INT); this.consumerID = buffer.readLong(); this.deliveryCount = buffer.readInt(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part receiveMessage(copyMessageBuffer(buffer.byteBuf(), DataConstants.SIZE_LONG + DataConstants.SIZE_INT)); buffer.readerIndex(buffer.capacity() - DataConstants.SIZE_LONG - DataConstants.SIZE_INT); this.consumerID = buffer.readLong(); this.deliveryCount = buffer.readInt(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part receiveMessage(copyMessageBuffer(buffer.byteBuf(), DataConstants.SIZE_LONG + DataConstants.SIZE_INT)); buffer.readerIndex(buffer.capacity() - DataConstants.SIZE_LONG - DataConstants.SIZE_INT); this.consumerID = buffer.readLong(); this.deliveryCount = buffer.readInt(); }
public static void assertEqualsBuffers(final int size, final ActiveMQBuffer expected, final ActiveMQBuffer actual) { // assertEquals(expected.length, actual.length); expected.readerIndex(0); actual.readerIndex(0); for (int i = 0; i < size; i++) { byte b1 = expected.readByte(); byte b2 = actual.readByte(); Assert.assertEquals("byte at index " + i, b1, b2); } expected.resetReaderIndex(); actual.resetReaderIndex(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part ByteBuf messageBuffer = copyMessageBuffer(buffer.byteBuf(), fieldsEncodeSize()); receiveMessage(messageBuffer); buffer.readerIndex(buffer.capacity() - fieldsEncodeSize()); requiresResponse = buffer.readBoolean(); }
@Override public void decodeRest(final ActiveMQBuffer buffer) { // Buffer comes in after having read standard headers and positioned at Beginning of body part ByteBuf messageBuffer = copyMessageBuffer(buffer.byteBuf(), fieldsEncodeSize()); receiveMessage(messageBuffer); buffer.readerIndex(buffer.capacity() - fieldsEncodeSize()); requiresResponse = buffer.readBoolean(); }
@Override public void write(final ActiveMQBuffer bytes, final boolean sync) throws Exception { bytes.writerIndex(bytes.capacity()); bytes.readerIndex(0); writeDirect(bytes.toByteBuffer(), sync); }