Class ClientReceiver

    • Method Detail

      • receive

        public Delivery receive()
                         throws ClientException
        Description copied from interface: Receiver
        Blocking receive method that waits forever for the remote to provide a Delivery 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 interface Receiver
        Returns:
        a new Delivery received from the remote.
        Throws:
        ClientException - if the Receiver or 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: Receiver
        Blocking receive method that waits the given time interval for the remote to provide a Delivery for consumption. The amount of time this method blocks is based on the timeout value. If timeout is equal to -1 then it blocks until a Delivery is received. If timeout is equal to zero then it will not block and simply return a Delivery if 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 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 incoming Delivery.

        Specified by:
        receive in interface Receiver
        Parameters:
        timeout - The timeout value used to control how long the receive method waits for a new Delivery.
        units - The unit of time that the given timeout represents.
        Returns:
        a new Delivery received from the remote.
        Throws:
        ClientException - if the Receiver or its parent is closed when the call to receive is made.
      • tryReceive

        public Delivery tryReceive()
                            throws ClientException
        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 interface Receiver
        Returns:
        a new Delivery received from the remote or null if no pending deliveries are available.
        Throws:
        ClientException - if the Receiver 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 the Receiver delivery queue. This number is likely to change immediately following the call as more deliveries arrive but can be used to determine if any pending Delivery work is ready.
        Specified by:
        queuedDeliveries in interface Receiver
        Returns:
        the number of deliveries that are currently buffered locally.
      • addCredit

        public Receiver addCredit​(int credits)
                           throws ClientException
        Description copied from interface: Receiver
        Adds credit to the Receiver 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.

        Specified by:
        addCredit in interface Receiver
        Parameters:
        credits - The number of credits to add to the Receiver link.
        Returns:
        this Receiver instance.
        Throws:
        ClientException - if an error occurs while attempting to add new Receiver link credit.
      • drain

        public java.util.concurrent.Future<Receiver> drain()
                                                    throws ClientException
        Description copied from interface: Receiver
        Requests the remote to drain previously granted credit for this Receiver link.
        Specified by:
        drain in interface Receiver
        Returns:
        a Future that will be completed when the remote drains this Receiver link.
        Throws:
        ClientException - if an error occurs while attempting to drain the link credit.