Class ClientReceiver
- All Implemented Interfaces:
AutoCloseable
,Link<Receiver>
,Receiver
Receiver
implementation.-
Field Summary
Fields inherited from class org.apache.qpid.protonj2.client.impl.ClientReceiverLinkType
drainingFuture, drainingTimeout, protonReceiver
Fields inherited from class org.apache.qpid.protonj2.client.impl.ClientLinkType
closed, CLOSED_UPDATER, closeFuture, executor, failureCause, linkId, linkRemotelyClosedHandler, openFuture, remoteSource, remoteTarget, session
-
Method Summary
Modifier and TypeMethodDescriptionaddCredit
(int credits) Adds credit to theReceiver
link for use when there receiver has not been configured with a credit window.drain()
Requests the remote to drain previously granted credit for thisReceiver
link.protected void
handleDeliveryRead
(IncomingDelivery delivery) protected void
long
Returns the number of Deliveries that are currently held in theReceiver
delivery queue.receive()
Blocking receive method that waits forever for the remote to provide aDelivery
for consumption.Blocking receive method that waits the given time interval for the remote to provide aDelivery
for consumption.protected void
protected void
protected Receiver
self()
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 class org.apache.qpid.protonj2.client.impl.ClientReceiverLinkType
handleDeliveryAborted, handleDeliveryStateRemotelyUpdated, handleReceiverCreditUpdated, linkSpecificCleanupHandler, linkSpecificLocalOpenHandler, linkSpecificRemoteCloseHandler, linkSpecificRemoteOpenHandler, protonLink
Methods inherited from class org.apache.qpid.protonj2.client.impl.ClientLinkType
address, checkClosedOrFailed, client, close, close, closeAsync, closeAsync, connection, desiredCapabilities, detach, detach, detachAsync, detachAsync, handleEngineShutdown, handleLocalCloseOrDetach, handleLocalOpen, handleParentEndpointClosed, handleRemoteCloseOrDetach, handleRemoteOpen, immediateLinkShutdown, notClosedOrFailed, notClosedOrFailed, offeredCapabilities, openFuture, properties, session, source, target, waitForOpenToComplete
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.qpid.protonj2.client.Link
address, client, close, close, closeAsync, closeAsync, connection, desiredCapabilities, detach, detach, detachAsync, detachAsync, offeredCapabilities, openFuture, properties, session, source, target
-
Method Details
-
receive
Description copied from interface:Receiver
Blocking receive method that waits forever for the remote to provide aDelivery
for consumption.Receive calls will only grant credit on their own if a credit window is configured in the
ReceiverOptions
which 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:
receive
in interfaceReceiver
- Returns:
- a new
Delivery
received from the remote. - Throws:
ClientException
- if theReceiver
or its parent is closed when the call to receive is made.
-
receive
Description copied from interface:Receiver
Blocking receive method that waits the given time interval for the remote to provide aDelivery
for consumption. The amount of time this method blocks is based on the timeout value. If the timeout is less than zero then it blocks until a Delivery is received. If the timeout is equal to zero then it will not block and simply return aDelivery
if one is available locally. If the 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
ReceiverOptions
which 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 incomingDelivery
.- Specified by:
receive
in interfaceReceiver
- Parameters:
timeout
- The timeout value used to control how long the receive method waits for a newDelivery
.units
- The unit of time that the given timeout represents.- Returns:
- a new
Delivery
received from the remote. - Throws:
ClientException
- if theReceiver
or its parent is closed when the call to receive is made.
-
tryReceive
Description copied from interface:Receiver
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:
tryReceive
in interfaceReceiver
- Returns:
- a new
Delivery
received from the remote or null if no pending deliveries are available. - Throws:
ClientException
- if theReceiver
or its parent is closed when the call to try to receive is made.
-
queuedDeliveries
public long queuedDeliveries()Description copied from interface:Receiver
Returns the number of Deliveries that are currently held in theReceiver
delivery queue. This number is likely to change immediately following the call as more deliveries arrive but can be used to determine if any pendingDelivery
work is ready.- Specified by:
queuedDeliveries
in interfaceReceiver
- Returns:
- the number of deliveries that are currently buffered locally.
-
addCredit
Description copied from interface:Receiver
Adds credit to theReceiver
link 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
Receiver
is 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. -
drain
Description copied from interface:Receiver
Requests the remote to drain previously granted credit for thisReceiver
link.- Specified by:
drain
in interfaceReceiver
- Returns:
- a
Future
that will be completed when the remote drains thisReceiver
link. - Throws:
ClientException
- if an error occurs while attempting to drain the link credit.
-
self
- Specified by:
self
in classClientLinkType<Receiver,
Receiver>
-
handleDeliveryRead
- Specified by:
handleDeliveryRead
in classClientReceiverLinkType<Receiver>
-
replenishCreditIfNeeded
protected void replenishCreditIfNeeded()- Specified by:
replenishCreditIfNeeded
in classClientReceiverLinkType<Receiver>
-
linkSpecificLocalCloseHandler
protected void linkSpecificLocalCloseHandler()- Overrides:
linkSpecificLocalCloseHandler
in classClientReceiverLinkType<Receiver>
-
recreateLinkForReconnect
protected void recreateLinkForReconnect()- Specified by:
recreateLinkForReconnect
in classClientLinkType<Receiver,
Receiver>
-