Search in sources :

Example 46 with Connection

use of com.swiftmq.amqp.v100.client.Connection in project qpid-protonj2 by apache.

the class StreamReceiverTest method testStreamSupportsMark.

@Test
public void testStreamSupportsMark() throws Exception {
    final byte[] payload = createEncodedMessage(new Data(new byte[] { 0, 1, 2, 3, 4, 5 }));
    try (ProtonTestServer peer = new ProtonTestServer()) {
        peer.expectSASLAnonymousConnect();
        peer.expectOpen().respond();
        peer.expectBegin().respond();
        peer.expectAttach().withRole(Role.RECEIVER.getValue()).respond();
        peer.expectFlow();
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(false).withMessageFormat(0).withPayload(payload).queue();
        peer.expectDisposition().withState().accepted().withSettled(true);
        peer.start();
        URI remoteURI = peer.getServerURI();
        LOG.info("Test started, peer listening on: {}", remoteURI);
        final Client container = Client.create();
        final Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort());
        final StreamReceiver receiver = connection.openStreamReceiver("test-queue");
        final StreamDelivery delivery = receiver.receive();
        assertNotNull(delivery);
        assertTrue(delivery.completed());
        assertFalse(delivery.aborted());
        final InputStream stream = delivery.rawInputStream();
        assertNotNull(stream);
        assertTrue(stream.markSupported());
        assertEquals(payload.length, stream.available());
        stream.mark(payload.length);
        final byte[] deliveryBytes1 = new byte[payload.length];
        final byte[] deliveryBytes2 = new byte[payload.length];
        stream.read(deliveryBytes1);
        stream.reset();
        stream.read(deliveryBytes2);
        assertNotSame(deliveryBytes1, deliveryBytes2);
        assertArrayEquals(payload, deliveryBytes1);
        assertArrayEquals(payload, deliveryBytes2);
        assertEquals(0, stream.available());
        assertTrue(delivery.completed());
        assertFalse(delivery.aborted());
        stream.close();
        peer.expectDetach().respond();
        peer.expectEnd().respond();
        peer.expectClose().respond();
        receiver.close();
        connection.close();
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
    }
}
Also used : StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) InputStream(java.io.InputStream) Connection(org.apache.qpid.protonj2.client.Connection) Data(org.apache.qpid.protonj2.types.messaging.Data) Client(org.apache.qpid.protonj2.client.Client) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 47 with Connection

use of com.swiftmq.amqp.v100.client.Connection in project qpid-protonj2 by apache.

the class StreamReceiverTest method testConnectionDropsDuringStreamedBodyRead.

@Test
public void testConnectionDropsDuringStreamedBodyRead() throws Exception {
    final byte[] body1 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    final byte[] body2 = new byte[] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    final byte[] payload1 = createEncodedMessage(new Data(body1));
    final byte[] payload2 = createEncodedMessage(new Data(body2));
    final CountDownLatch disconnected = new CountDownLatch(1);
    try (ProtonTestServer peer = new ProtonTestServer()) {
        peer.expectSASLAnonymousConnect();
        peer.expectOpen().withMaxFrameSize(1000).respond();
        peer.expectBegin().withIncomingWindow(1).respond();
        peer.expectAttach().ofReceiver().respond();
        peer.expectFlow().withIncomingWindow(1).withLinkCredit(1);
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(true).withMessageFormat(0).withPayload(payload1).queue();
        peer.start();
        URI remoteURI = peer.getServerURI();
        LOG.info("Test started, peer listening on: {}", remoteURI);
        Client container = Client.create();
        ConnectionOptions connectionOptions = new ConnectionOptions().maxFrameSize(1000);
        connectionOptions.disconnectedHandler((conn, event) -> disconnected.countDown());
        Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort(), connectionOptions);
        StreamReceiverOptions streamOptions = new StreamReceiverOptions().readBufferSize(2000).creditWindow(1);
        StreamReceiver receiver = connection.openStreamReceiver("test-queue", streamOptions);
        StreamDelivery delivery = receiver.receive();
        StreamReceiverMessage message = delivery.message();
        // Creating the input stream instance should read the first chunk of data from the incoming
        // delivery which should result in a new credit being available to expand the session window.
        // An additional transfer should be placed into the delivery buffer but not yet read since
        // the user hasn't read anything.
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
        peer.expectFlow().withDeliveryCount(0).withIncomingWindow(1).withLinkCredit(1);
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withMore(true).withMessageFormat(0).withPayload(payload2).queue();
        peer.dropAfterLastHandler();
        InputStream bodyStream = message.body();
        assertNotNull(bodyStream);
        assertTrue(disconnected.await(5, TimeUnit.SECONDS));
        byte[] readPayload = new byte[body1.length + body2.length];
        try {
            bodyStream.read(readPayload);
            fail("Should not be able to read from closed connection stream");
        } catch (IOException ioe) {
        // Connection should be down now.
        }
        bodyStream.close();
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
    }
}
Also used : ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) StreamReceiverOptions(org.apache.qpid.protonj2.client.StreamReceiverOptions) InputStream(java.io.InputStream) Connection(org.apache.qpid.protonj2.client.Connection) Data(org.apache.qpid.protonj2.types.messaging.Data) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) URI(java.net.URI) StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) StreamReceiverMessage(org.apache.qpid.protonj2.client.StreamReceiverMessage) ConnectionOptions(org.apache.qpid.protonj2.client.ConnectionOptions) Client(org.apache.qpid.protonj2.client.Client) Test(org.junit.jupiter.api.Test)

Example 48 with Connection

use of com.swiftmq.amqp.v100.client.Connection in project qpid-protonj2 by apache.

the class StreamReceiverTest method testStreamReceiverMessageThrowsOnAnyMessageModificationAPI.

@Test
public void testStreamReceiverMessageThrowsOnAnyMessageModificationAPI() throws Exception {
    final byte[] body = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    final byte[] payload = createEncodedMessage(new Data(body));
    try (ProtonTestServer peer = new ProtonTestServer()) {
        peer.expectSASLAnonymousConnect();
        peer.expectOpen().respond();
        peer.expectBegin().respond();
        peer.expectAttach().withRole(Role.RECEIVER.getValue()).respond();
        peer.expectFlow();
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(false).withMessageFormat(0).withPayload(payload).queue();
        peer.expectDisposition().withFirst(0).withState().accepted().withSettled(true);
        peer.start();
        URI remoteURI = peer.getServerURI();
        LOG.info("Test started, peer listening on: {}", remoteURI);
        final Client container = Client.create();
        final Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort());
        final StreamReceiver receiver = connection.openStreamReceiver("test-queue");
        final StreamDelivery delivery = receiver.receive();
        final StreamReceiverMessage message = delivery.message();
        assertThrows(ClientUnsupportedOperationException.class, () -> message.header(new Header()));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.properties(new Properties()));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.applicationProperties(new ApplicationProperties(null)));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.annotations(new MessageAnnotations(null)));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.footer(new Footer(null)));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.messageFormat(1));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.durable(true));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.priority((byte) 4));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.timeToLive(128));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.firstAcquirer(false));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.deliveryCount(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.messageId(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.correlationId(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.userId(new byte[] { 1 }));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.to("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.subject("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.replyTo("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.contentType("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.contentEncoding("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.absoluteExpiryTime(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.creationTime(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.groupId("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.groupSequence(10));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.replyToGroupId("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.annotation("test", 1));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.removeAnnotation("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.property("test", 1));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.removeProperty("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.footer("test", 1));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.removeFooter("test"));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.body(InputStream.nullInputStream()));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.addBodySection(new AmqpValue<>("test")));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.bodySections(Collections.emptyList()));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.bodySections());
        assertThrows(ClientUnsupportedOperationException.class, () -> message.clearBodySections());
        assertThrows(ClientUnsupportedOperationException.class, () -> message.forEachBodySection((section) -> {
        }));
        assertThrows(ClientUnsupportedOperationException.class, () -> message.encode(Collections.emptyMap()));
        InputStream bodyStream = message.body();
        assertNotNull(bodyStream.readAllBytes());
        bodyStream.close();
        peer.expectDetach().respond();
        peer.expectEnd().respond();
        peer.expectClose().respond();
        receiver.closeAsync().get();
        connection.closeAsync().get();
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
    }
}
Also used : Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) Properties(org.apache.qpid.protonj2.types.messaging.Properties) Random(java.util.Random) ImperativeClientTestCase(org.apache.qpid.protonj2.client.test.ImperativeClientTestCase) Future(java.util.concurrent.Future) ClientLinkRemotelyClosedException(org.apache.qpid.protonj2.client.exceptions.ClientLinkRemotelyClosedException) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Data(org.apache.qpid.protonj2.types.messaging.Data) Map(java.util.Map) URI(java.net.URI) ClientOperationTimedOutException(org.apache.qpid.protonj2.client.exceptions.ClientOperationTimedOutException) Accepted(org.apache.qpid.protonj2.test.driver.codec.messaging.Accepted) EncodingCodes(org.apache.qpid.protonj2.codec.EncodingCodes) ReceiverOptions(org.apache.qpid.protonj2.client.ReceiverOptions) SenderOptions(org.apache.qpid.protonj2.client.SenderOptions) Binary(org.apache.qpid.protonj2.types.Binary) Footer(org.apache.qpid.protonj2.types.messaging.Footer) UUID(java.util.UUID) Assertions.assertNotSame(org.junit.jupiter.api.Assertions.assertNotSame) StreamReceiverMessage(org.apache.qpid.protonj2.client.StreamReceiverMessage) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Connection(org.apache.qpid.protonj2.client.Connection) Client(org.apache.qpid.protonj2.client.Client) ClientUnsupportedOperationException(org.apache.qpid.protonj2.client.exceptions.ClientUnsupportedOperationException) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) AmqpValue(org.apache.qpid.protonj2.types.messaging.AmqpValue) ApplicationProperties(org.apache.qpid.protonj2.types.messaging.ApplicationProperties) Wait(org.apache.qpid.protonj2.client.test.Wait) Symbol(org.apache.qpid.protonj2.types.Symbol) ArrayList(java.util.ArrayList) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) ClientException(org.apache.qpid.protonj2.client.exceptions.ClientException) DeliveryState(org.apache.qpid.protonj2.client.DeliveryState) UnsignedInteger(org.apache.qpid.protonj2.types.UnsignedInteger) ConnectionOptions(org.apache.qpid.protonj2.client.ConnectionOptions) Role(org.apache.qpid.protonj2.types.transport.Role) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Header(org.apache.qpid.protonj2.types.messaging.Header) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Logger(org.slf4j.Logger) DeliveryAnnotations(org.apache.qpid.protonj2.test.driver.codec.messaging.DeliveryAnnotations) ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) ClientIllegalStateException(org.apache.qpid.protonj2.client.exceptions.ClientIllegalStateException) IOException(java.io.IOException) ClientDeliveryAbortedException(org.apache.qpid.protonj2.client.exceptions.ClientDeliveryAbortedException) StreamReceiverOptions(org.apache.qpid.protonj2.client.StreamReceiverOptions) ErrorCondition(org.apache.qpid.protonj2.client.ErrorCondition) AmqpSequence(org.apache.qpid.protonj2.types.messaging.AmqpSequence) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MessageAnnotations(org.apache.qpid.protonj2.types.messaging.MessageAnnotations) StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) Collections(java.util.Collections) Timeout(org.junit.jupiter.api.Timeout) InputStream(java.io.InputStream) ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) InputStream(java.io.InputStream) Connection(org.apache.qpid.protonj2.client.Connection) Data(org.apache.qpid.protonj2.types.messaging.Data) Properties(org.apache.qpid.protonj2.types.messaging.Properties) ApplicationProperties(org.apache.qpid.protonj2.types.messaging.ApplicationProperties) URI(java.net.URI) AmqpValue(org.apache.qpid.protonj2.types.messaging.AmqpValue) StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) Header(org.apache.qpid.protonj2.types.messaging.Header) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) StreamReceiverMessage(org.apache.qpid.protonj2.client.StreamReceiverMessage) MessageAnnotations(org.apache.qpid.protonj2.types.messaging.MessageAnnotations) Footer(org.apache.qpid.protonj2.types.messaging.Footer) ApplicationProperties(org.apache.qpid.protonj2.types.messaging.ApplicationProperties) Client(org.apache.qpid.protonj2.client.Client) Test(org.junit.jupiter.api.Test)

Example 49 with Connection

use of com.swiftmq.amqp.v100.client.Connection in project qpid-protonj2 by apache.

the class StreamReceiverTest method testStreamDeliveryRawInputStreamWithInCompleteDeliverySkipBytes.

@Test
public void testStreamDeliveryRawInputStreamWithInCompleteDeliverySkipBytes() throws Exception {
    final byte[] payload1 = createEncodedMessage(new Data(new byte[] { 0, 1, 2, 3, 4, 5 }));
    final byte[] payload2 = createEncodedMessage(new Data(new byte[] { 6, 7, 8, 9, 0, 1 }));
    try (ProtonTestServer peer = new ProtonTestServer()) {
        peer.expectSASLAnonymousConnect();
        peer.expectOpen().respond();
        peer.expectBegin().respond();
        peer.expectAttach().withRole(Role.RECEIVER.getValue()).respond();
        peer.expectFlow();
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(true).withMessageFormat(0).withPayload(payload1).queue();
        peer.expectDisposition().withState().accepted().withSettled(true);
        peer.start();
        URI remoteURI = peer.getServerURI();
        LOG.info("Test started, peer listening on: {}", remoteURI);
        final Client container = Client.create();
        final Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort());
        final StreamReceiver receiver = connection.openStreamReceiver("test-queue");
        final StreamDelivery delivery = receiver.receive();
        assertNotNull(delivery);
        assertFalse(delivery.completed());
        assertFalse(delivery.aborted());
        final InputStream stream = delivery.rawInputStream();
        assertNotNull(stream);
        assertEquals(payload1.length, stream.available());
        stream.skip(payload1.length);
        assertEquals(0, stream.available());
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(false).withPayload(payload2).later(50);
        // Should block until more data arrives.
        stream.skip(payload2.length);
        assertEquals(0, stream.available());
        assertTrue(delivery.completed());
        assertFalse(delivery.aborted());
        stream.close();
        peer.expectDetach().respond();
        peer.expectEnd().respond();
        peer.expectClose().respond();
        receiver.close();
        connection.close();
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
    }
}
Also used : StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) InputStream(java.io.InputStream) Connection(org.apache.qpid.protonj2.client.Connection) Data(org.apache.qpid.protonj2.types.messaging.Data) Client(org.apache.qpid.protonj2.client.Client) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 50 with Connection

use of com.swiftmq.amqp.v100.client.Connection in project qpid-protonj2 by apache.

the class StreamReceiverTest method testStreamDeliveryRawInputStreamWithCompleteDeliveryReadByte.

@Test
public void testStreamDeliveryRawInputStreamWithCompleteDeliveryReadByte() throws Exception {
    final byte[] payload = createEncodedMessage(new AmqpValue<>("Hello World"));
    try (ProtonTestServer peer = new ProtonTestServer()) {
        peer.expectSASLAnonymousConnect();
        peer.expectOpen().respond();
        peer.expectBegin().respond();
        peer.expectAttach().withRole(Role.RECEIVER.getValue()).respond();
        peer.expectFlow();
        peer.remoteTransfer().withHandle(0).withDeliveryId(0).withDeliveryTag(new byte[] { 1 }).withMore(false).withMessageFormat(0).withPayload(payload).queue();
        peer.expectDisposition().withState().accepted().withSettled(true);
        peer.start();
        URI remoteURI = peer.getServerURI();
        LOG.info("Test started, peer listening on: {}", remoteURI);
        final Client container = Client.create();
        final Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort());
        final StreamReceiver receiver = connection.openStreamReceiver("test-queue");
        final StreamDelivery delivery = receiver.receive();
        assertNotNull(delivery);
        assertTrue(delivery.completed());
        assertFalse(delivery.aborted());
        final InputStream stream = delivery.rawInputStream();
        assertNotNull(stream);
        assertEquals(payload.length, stream.available());
        final byte[] deliveryBytes = new byte[payload.length];
        for (int i = 0; i < payload.length; ++i) {
            deliveryBytes[i] = (byte) stream.read();
        }
        assertArrayEquals(payload, deliveryBytes);
        assertEquals(0, stream.available());
        assertEquals(-1, stream.read());
        stream.close();
        peer.expectDetach().respond();
        peer.expectEnd().respond();
        peer.expectClose().respond();
        receiver.close();
        connection.closeAsync().get();
        peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
    }
}
Also used : StreamDelivery(org.apache.qpid.protonj2.client.StreamDelivery) ProtonTestServer(org.apache.qpid.protonj2.test.driver.ProtonTestServer) StreamReceiver(org.apache.qpid.protonj2.client.StreamReceiver) InputStream(java.io.InputStream) Connection(org.apache.qpid.protonj2.client.Connection) Client(org.apache.qpid.protonj2.client.Client) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Aggregations

Connection (org.apache.qpid.protonj2.client.Connection)368 Client (org.apache.qpid.protonj2.client.Client)367 URI (java.net.URI)354 ProtonTestServer (org.apache.qpid.protonj2.test.driver.ProtonTestServer)352 Test (org.junit.jupiter.api.Test)250 Session (org.apache.qpid.protonj2.client.Session)166 ConnectionOptions (org.apache.qpid.protonj2.client.ConnectionOptions)112 Sender (org.apache.qpid.protonj2.client.Sender)89 Receiver (org.apache.qpid.protonj2.client.Receiver)79 ExecutionException (java.util.concurrent.ExecutionException)72 StreamReceiver (org.apache.qpid.protonj2.client.StreamReceiver)65 ClientException (org.apache.qpid.protonj2.client.exceptions.ClientException)60 StreamSender (org.apache.qpid.protonj2.client.StreamSender)49 StreamDelivery (org.apache.qpid.protonj2.client.StreamDelivery)46 TransferPayloadCompositeMatcher (org.apache.qpid.protonj2.test.driver.matchers.transport.TransferPayloadCompositeMatcher)44 Tracker (org.apache.qpid.protonj2.client.Tracker)41 StreamSenderMessage (org.apache.qpid.protonj2.client.StreamSenderMessage)38 ReceiverOptions (org.apache.qpid.protonj2.client.ReceiverOptions)34 SenderOptions (org.apache.qpid.protonj2.client.SenderOptions)33 OutputStream (java.io.OutputStream)31