Interface StreamReceiver
-
- All Superinterfaces:
java.lang.AutoCloseable,Receiver
- All Known Implementing Classes:
ClientStreamReceiver
public interface StreamReceiver extends Receiver
A receiver of large message content that is delivered in multipleTransferframes from the remote.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StreamReceiveraddCredit(int credits)Adds credit to theReceiverlink for use when there receiver has not been configured with a credit window.StreamDeliveryreceive()Blocking receive method that waits forever for the remote to provide aStreamReceiverMessagefor consumption.StreamDeliveryreceive(long timeout, java.util.concurrent.TimeUnit unit)Blocking receive method that waits the given time interval for the remote to provide aStreamReceiverMessagefor consumption.StreamDeliverytryReceive()Non-blocking receive method that either returns a message is one is immediately available or returns null if none is currently at hand.-
Methods inherited from interface org.apache.qpid.protonj2.client.Receiver
address, client, close, close, closeAsync, closeAsync, connection, desiredCapabilities, detach, detach, detachAsync, detachAsync, drain, offeredCapabilities, openFuture, properties, queuedDeliveries, session, source, target
-
-
-
-
Method Detail
-
receive
StreamDelivery receive() throws ClientException
Blocking receive method that waits forever for the remote to provide aStreamReceiverMessagefor consumption.Receive calls will only grant credit on their own if a credit window is configured in the
StreamReceiverOptionswhich is done by default. If the client application has configured no credit window than this method will not grant any credit when it enters the wait for new incoming messages.- Specified by:
receivein interfaceReceiver- Returns:
- a new
Deliveryreceived from the remote. - Throws:
ClientException- if theStreamReceiveror its parent is closed when the call to receive is made.
-
receive
StreamDelivery receive(long timeout, java.util.concurrent.TimeUnit unit) throws ClientException
Blocking receive method that waits the given time interval for the remote to provide aStreamReceiverMessagefor consumption. The amount of time this method blocks is based on the timeout value. If timeout is equal to-1then it blocks until a Delivery is received. If timeout is equal to zero then it will not block and simply return aStreamReceiverMessageif one is available locally. If timeout value is greater than zero then it blocks up to timeout amount of time.Receive calls will only grant credit on their own if a credit window is configured in the
StreamReceiverOptionswhich is done by default. If the client application has not configured a credit window or granted credit manually this method will not automatically grant any credit when it enters the wait for a new incomingStreamReceiverMessage.- Specified by:
receivein interfaceReceiver- Parameters:
timeout- The timeout value used to control how long the receive method waits for a newDelivery.unit- The unit of time that the given timeout represents.- Returns:
- a new
StreamReceiverMessagereceived from the remote. - Throws:
ClientException- if theStreamReceiveror its parent is closed when the call to receive is made.
-
tryReceive
StreamDelivery tryReceive() throws ClientException
Non-blocking receive method that either returns a message is one is immediately available or returns null if none is currently at hand.- Specified by:
tryReceivein interfaceReceiver- Returns:
- a new
StreamReceiverMessagereceived from the remote or null if no pending deliveries are available. - Throws:
ClientException- if theStreamReceiveror its parent is closed when the call to try to receive is made.
-
addCredit
StreamReceiver addCredit(int credits) throws ClientException
Adds credit to theReceiverlink for use when there receiver has not been configured with a credit window. When credit window is configured credit replenishment is automatic and calling this method will result in an exception indicating that the operation is invalid.If the
Receiveris draining and this method is called an exception will be thrown to indicate that credit cannot be replenished until the remote has drained the existing link credit.- Specified by:
addCreditin interfaceReceiver- Parameters:
credits- credit The number of credits to add to theStreamReceiverlink.- Returns:
- this
StreamReceiverinstance. - Throws:
ClientException- if an error occurs while attempting to add newStreamReceiverlink credit.
-
-