use of org.apache.activemq.artemis.utils.ActiveMQBufferInputStream in project activemq-artemis by apache.
the class ClientProducerImpl method largeMessageSendBuffered.
/**
* @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);
}
use of org.apache.activemq.artemis.utils.ActiveMQBufferInputStream in project activemq-artemis by apache.
the class CompressedLargeMessageControllerImpl method getStream.
private DataInputStream getStream() {
if (dataInput == null) {
try {
InputStream input = new ActiveMQBufferInputStream(bufferDelegate);
dataInput = new DataInputStream(new InflaterReader(input));
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
return dataInput;
}
use of org.apache.activemq.artemis.utils.ActiveMQBufferInputStream in project activemq-artemis by apache.
the class JDBCJournalRecord method setTxData.
void setTxData(EncodingSupport txData) {
this.txDataSize = txData.getEncodeSize();
ActiveMQBuffer encodedBuffer = ActiveMQBuffers.fixedBuffer(txDataSize);
txData.encode(encodedBuffer);
this.txData = new ActiveMQBufferInputStream(encodedBuffer);
}
use of org.apache.activemq.artemis.utils.ActiveMQBufferInputStream in project activemq-artemis by apache.
the class LargeMessageBufferTest method testReadBytesOnStreaming.
@Test
public void testReadBytesOnStreaming() throws Exception {
byte[] byteArray = new byte[1024];
for (int i = 0; i < byteArray.length; i++) {
byteArray[i] = getSamplebyte(i);
}
ActiveMQBuffer splitbuffer = splitBuffer(3, byteArray);
ActiveMQBufferInputStream is = new ActiveMQBufferInputStream(splitbuffer);
for (int i = 0; i < 100; i++) {
assertEquals(getSamplebyte(i), (byte) is.read());
}
for (int i = 100; i < byteArray.length; i += 10) {
byte[] readBytes = new byte[10];
int size = is.read(readBytes);
for (int j = 0; j < size; j++) {
assertEquals(getSamplebyte(i + j), readBytes[j]);
}
}
is.close();
}
use of org.apache.activemq.artemis.utils.ActiveMQBufferInputStream in project activemq-artemis by apache.
the class LargeMessageBufferTest method testReadLongsOverStream.
@Test
public void testReadLongsOverStream() throws Exception {
LargeMessageControllerImpl buffer = createBufferWithLongs(3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
ActiveMQBufferInputStream is = new ActiveMQBufferInputStream(buffer);
DataInputStream dataInput = new DataInputStream(is);
for (int i = 1; i <= 15; i++) {
Assert.assertEquals(i, dataInput.readLong());
}
assertEquals(-1, dataInput.read());
dataInput.close();
}
Aggregations