Search in sources :

Example 1 with ActiveMQBufferInputStream

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);
}
Also used : ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream)

Example 2 with ActiveMQBufferInputStream

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;
}
Also used : InflaterReader(org.apache.activemq.artemis.utils.InflaterReader) DataInputStream(java.io.DataInputStream) ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream) InputStream(java.io.InputStream) DataInputStream(java.io.DataInputStream) ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream) IOException(java.io.IOException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException)

Example 3 with ActiveMQBufferInputStream

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);
}
Also used : ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 4 with ActiveMQBufferInputStream

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();
}
Also used : ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 5 with ActiveMQBufferInputStream

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();
}
Also used : LargeMessageControllerImpl(org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl) DataInputStream(java.io.DataInputStream) ActiveMQBufferInputStream(org.apache.activemq.artemis.utils.ActiveMQBufferInputStream) Test(org.junit.Test)

Aggregations

ActiveMQBufferInputStream (org.apache.activemq.artemis.utils.ActiveMQBufferInputStream)8 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)4 Test (org.junit.Test)4 DataInputStream (java.io.DataInputStream)3 LargeMessageControllerImpl (org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 InflaterReader (org.apache.activemq.artemis.utils.InflaterReader)1