Class ClientReceiver
- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientReceiver
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReceiveraddCredit(int credits)Adds credit to theReceiverlink for use when there receiver has not been configured with a credit window.java.lang.Stringaddress()Returns the address that theReceiverinstance will be subscribed to.ClientInstanceclient()voidclose()Requests a close of theReceiverat the remote and waits until the Receiver has been fully closed or until the configuredReceiverOptions.closeTimeout()is exceeded.voidclose(ErrorCondition error)Requests a close of theReceiverat the remote and waits until the Receiver has been fully closed or until the configuredReceiverOptions.closeTimeout()is exceeded.ClientFuture<Receiver>closeAsync()Requests a close of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been closed.ClientFuture<Receiver>closeAsync(ErrorCondition error)Requests a close of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been closed.ClientConnectionconnection()java.lang.String[]desiredCapabilities()Returns the desired capabilities that the remote provided upon successfully opening theReceiver.voiddetach()Requests a detach of theReceiverat the remote and waits until the Receiver has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.voiddetach(ErrorCondition error)Requests a detach of theReceiverat the remote and waits until the Receiver has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.ClientFuture<Receiver>detachAsync()Requests a detach of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been detached.ClientFuture<Receiver>detachAsync(ErrorCondition error)Requests a detach of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been detached.java.util.concurrent.Future<Receiver>drain()Requests the remote to drain previously granted credit for thisReceiverlink.java.lang.String[]offeredCapabilities()Returns the offered capabilities that the remote provided upon successfully opening theReceiver.java.util.concurrent.Future<Receiver>openFuture()java.util.Map<java.lang.String,java.lang.Object>properties()Returns the properties that the remote provided upon successfully opening theReceiver.longqueuedDeliveries()Returns the number of Deliveries that are currently held in theReceiverdelivery queue.Deliveryreceive()Blocking receive method that waits forever for the remote to provide aDeliveryfor consumption.Deliveryreceive(long timeout, java.util.concurrent.TimeUnit units)Blocking receive method that waits the given time interval for the remote to provide aDeliveryfor consumption.ClientSessionsession()Sourcesource()Returns an immutable view of the remoteSourceobject assigned to this receiver link.Targettarget()Returns an immutable view of the remoteTargetobject assigned to this receiver link.DeliverytryReceive()Non-blocking receive method that either returns a message is one is immediately available or returns null if none is currently at hand.
-
-
-
Method Detail
-
address
public java.lang.String address() throws ClientExceptionDescription copied from interface:ReceiverReturns the address that theReceiverinstance will be subscribed to.- If the Receiver was created with the dynamic receiver methods then the method will return the dynamically created address once the remote has attached its end of the receiver link. Due to the need to await the remote peer to populate the dynamic address this method will block until the open of the receiver link has completed.
-
If not a dynamic receiver then the address returned is the address passed to the original
Session.openReceiver(String)orSession.openReceiver(String, ReceiverOptions)methods.
- Specified by:
addressin interfaceReceiver- Returns:
- the address that this
Receiveris sending to. - Throws:
ClientException- if an error occurs while obtaining theReceiveraddress.
-
source
public Source source() throws ClientException
Description copied from interface:Receiver
-
target
public Target target() throws ClientException
Description copied from interface:Receiver
-
client
public ClientInstance client()
-
connection
public ClientConnection connection()
- Specified by:
connectionin interfaceReceiver- Returns:
- the
Connectioninstance that holds this session'sReceiver
-
session
public ClientSession session()
-
openFuture
public java.util.concurrent.Future<Receiver> openFuture()
- Specified by:
openFuturein interfaceReceiver- Returns:
- a
Futurethat will be completed when the remote opens thisReceiver.
-
receive
public Delivery receive() throws ClientException
Description copied from interface:ReceiverBlocking receive method that waits forever for the remote to provide aDeliveryfor consumption.Receive calls will only grant credit on their own if a credit window is configured in the
ReceiverOptionswhich 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 theReceiveror its parent is closed when the call to receive is made.
-
receive
public Delivery receive(long timeout, java.util.concurrent.TimeUnit units) throws ClientException
Description copied from interface:ReceiverBlocking receive method that waits the given time interval for the remote to provide aDeliveryfor 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 aDeliveryif 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
ReceiverOptionswhich 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:
receivein 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
Deliveryreceived from the remote. - Throws:
ClientException- if theReceiveror its parent is closed when the call to receive is made.
-
tryReceive
public Delivery tryReceive() throws ClientException
Description copied from interface:ReceiverNon-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
Deliveryreceived from the remote or null if no pending deliveries are available. - Throws:
ClientException- if theReceiveror its parent is closed when the call to try to receive is made.
-
close
public void close()
Description copied from interface:ReceiverRequests a close of theReceiverat the remote and waits until the Receiver has been fully closed or until the configuredReceiverOptions.closeTimeout()is exceeded.
-
close
public void close(ErrorCondition error)
Description copied from interface:ReceiverRequests a close of theReceiverat the remote and waits until the Receiver has been fully closed or until the configuredReceiverOptions.closeTimeout()is exceeded.- Specified by:
closein interfaceReceiver- Parameters:
error- TheErrorConditionto transmit to the remote along with the close operation.
-
detach
public void detach()
Description copied from interface:ReceiverRequests a detach of theReceiverat the remote and waits until the Receiver has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.
-
detach
public void detach(ErrorCondition error)
Description copied from interface:ReceiverRequests a detach of theReceiverat the remote and waits until the Receiver has been fully detached or until the configuredSenderOptions.closeTimeout()is exceeded.- Specified by:
detachin interfaceReceiver- Parameters:
error- TheErrorConditionto transmit to the remote along with the detach operation.
-
closeAsync
public ClientFuture<Receiver> closeAsync()
Description copied from interface:ReceiverRequests a close of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been closed.- Specified by:
closeAsyncin interfaceReceiver- Returns:
- a
Futurethat will be completed when the remote closes thisReceiverlink.
-
closeAsync
public ClientFuture<Receiver> closeAsync(ErrorCondition error)
Description copied from interface:ReceiverRequests a close of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been closed.- Specified by:
closeAsyncin interfaceReceiver- Parameters:
error- TheErrorConditionto transmit to the remote along with the close operation.- Returns:
- a
Futurethat will be completed when the remote closes thisReceiverlink.
-
detachAsync
public ClientFuture<Receiver> detachAsync()
Description copied from interface:ReceiverRequests a detach of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been detached.- Specified by:
detachAsyncin interfaceReceiver- Returns:
- a
Futurethat will be completed when the remote detaches thisReceiverlink.
-
detachAsync
public ClientFuture<Receiver> detachAsync(ErrorCondition error)
Description copied from interface:ReceiverRequests a detach of theReceiverlink at the remote and returns aFuturethat will be completed once the link has been detached.- Specified by:
detachAsyncin interfaceReceiver- Parameters:
error- TheErrorConditionto transmit to the remote along with the detach operation.- Returns:
- a
Futurethat will be completed when the remote detaches thisReceiverlink.
-
queuedDeliveries
public long queuedDeliveries()
Description copied from interface:ReceiverReturns the number of Deliveries that are currently held in theReceiverdelivery queue. This number is likely to change immediately following the call as more deliveries arrive but can be used to determine if any pendingDeliverywork is ready.- Specified by:
queuedDeliveriesin interfaceReceiver- Returns:
- the number of deliveries that are currently buffered locally.
-
addCredit
public Receiver addCredit(int credits) throws ClientException
Description copied from interface:ReceiverAdds 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.
-
drain
public java.util.concurrent.Future<Receiver> drain() throws ClientException
Description copied from interface:ReceiverRequests the remote to drain previously granted credit for thisReceiverlink.- Specified by:
drainin interfaceReceiver- Returns:
- a
Futurethat will be completed when the remote drains thisReceiverlink. - Throws:
ClientException- if an error occurs while attempting to drain the link credit.
-
properties
public java.util.Map<java.lang.String,java.lang.Object> properties() throws ClientExceptionDescription copied from interface:ReceiverReturns the properties that the remote provided upon successfully opening theReceiver. If the attach has not completed yet this method will block to await the attach response which carries the remote properties. If the remote provides no properties this method will return null.- Specified by:
propertiesin interfaceReceiver- Returns:
- any properties provided from the remote once the receiver has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theReceiverremote properties.
-
offeredCapabilities
public java.lang.String[] offeredCapabilities() throws ClientExceptionDescription copied from interface:ReceiverReturns the offered capabilities that the remote provided upon successfully opening theReceiver. If the attach has not completed yet this method will block to await the attach response which carries the remote offered capabilities. If the remote provides no capabilities this method will return null.- Specified by:
offeredCapabilitiesin interfaceReceiver- Returns:
- any capabilities provided from the remote once the receiver has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theReceiverremote offered capabilities.
-
desiredCapabilities
public java.lang.String[] desiredCapabilities() throws ClientExceptionDescription copied from interface:ReceiverReturns the desired capabilities that the remote provided upon successfully opening theReceiver. If the attach has not completed yet this method will block to await the attach response which carries the remote desired capabilities. If the remote provides no capabilities this method will return null.- Specified by:
desiredCapabilitiesin interfaceReceiver- Returns:
- any desired capabilities provided from the remote once the receiver has successfully opened.
- Throws:
ClientException- if an error occurs while obtaining theReceiverremote desired capabilities.
-
-