Class ProtonReceiver

    • Constructor Detail

      • ProtonReceiver

        public ProtonReceiver​(ProtonSession session,
                              java.lang.String name)
        Create a new Receiver instance with the given Session parent.
        Parameters:
        session - The Session that is linked to this receiver instance.
        name - The name assigned to this Receiver link.
    • Method Detail

      • setDefaultDeliveryState

        public ProtonReceiver setDefaultDeliveryState​(DeliveryState state)
        Description copied from interface: Receiver
        Configures a default DeliveryState to be used if a received delivery is settled/freed without any disposition state having been previously applied.
        Specified by:
        setDefaultDeliveryState in interface Receiver
        Parameters:
        state - the default delivery state
        Returns:
        this Receiver for chaining.
      • getRole

        public Role getRole()
        Specified by:
        getRole in interface Link<Receiver>
        Returns:
        the Role that this end of the link is performing.
      • getCredit

        public int getCredit()
        Description copied from interface: Link
        Get the credit that is currently available or assigned to this link.
        Specified by:
        getCredit in interface Link<Receiver>
        Returns:
        the current link credit.
      • addCredit

        public ProtonReceiver addCredit​(int credit)
        Description copied from interface: Receiver
        Adds the given amount of credit for the Receiver.
        Specified by:
        addCredit in interface Receiver
        Parameters:
        credit - the new amount of credits to add.
        Returns:
        this Receiver
      • drain

        public boolean drain()
        Description copied from interface: Receiver
        Initiate a drain of all remaining credit of this Receiver link.
        Specified by:
        drain in interface Receiver
        Returns:
        true if a drain was started or false if the link already had no credit to drain.
      • drain

        public boolean drain​(int credits)
        Description copied from interface: Receiver
        Initiate a drain of the given credit from this this Receiver link. If the credit given is greater than the current link credit the current credit is increased, however if the amount of credit given is less that the current amount of link credit an exception is thrown.
        Specified by:
        drain in interface Receiver
        Parameters:
        credits - The amount of credit that should be requested to be drained from this link.
        Returns:
        true if a drain was started or false if the value is zero and the link had no credit.
      • isDraining

        public boolean isDraining()
        Description copied from interface: Link
        Indicates if the link is draining. For a Sender link this indicates that the remote has requested that the Sender transmit deliveries up to the currently available credit or indicate that it has no more to send. For a Receiver this indicates that the Receiver has requested that the Sender consume its outstanding credit.
        Specified by:
        isDraining in interface Link<Receiver>
        Returns:
        true if the Link is currently marked as draining.
      • disposition

        public Receiver disposition​(java.util.function.Predicate<IncomingDelivery> filter,
                                    DeliveryState disposition,
                                    boolean settle)
        Description copied from interface: Receiver
        For each unsettled outgoing delivery that is pending in the Receiver apply the given predicate and if it matches then apply the given delivery state and settled value to it.
        Specified by:
        disposition in interface Receiver
        Parameters:
        filter - The predicate to apply to each unsettled delivery to test for a match.
        disposition - The new DeliveryState to apply to any matching outgoing deliveries.
        settle - Boolean indicating if the matching unsettled deliveries should be settled.
        Returns:
        this Receiver for chaining
      • settle

        public Receiver settle​(java.util.function.Predicate<IncomingDelivery> filter)
        Description copied from interface: Receiver
        For each unsettled outgoing delivery that is pending in the Receiver apply the given predicate and if it matches then settle the delivery.
        Specified by:
        settle in interface Receiver
        Parameters:
        filter - The predicate to apply to each unsettled delivery to test for a match.
        Returns:
        this Receiver for chaining
      • unsettled

        public java.util.Collection<IncomingDelivery> unsettled()
        Description copied from interface: Receiver
        Retrieves the list of unsettled deliveries for this Receiver link which have yet to be settled on this end of the link. When the IncomingDelivery is settled by the receiver the value will be removed from the collection. The Collection returned from this method is a copy of the internally maintained data and is not modifiable. The caller should use this method judiciously to avoid excess GC overhead.
        Specified by:
        unsettled in interface Receiver
        Returns:
        a collection of unsettled deliveries or an empty list if no pending deliveries are outstanding.
      • hasUnsettled

        public boolean hasUnsettled()
        Specified by:
        hasUnsettled in interface Receiver
        Returns:
        true if there are unsettled deliveries for this Receiver link.
      • deliveryReadHandler

        public Receiver deliveryReadHandler​(EventHandler<IncomingDelivery> handler)
        Description copied from interface: Receiver
        Handler for incoming deliveries that is called for each incoming Transfer frame that comprises either one complete delivery or a chunk of a split framed Transfer. The handler should check that the delivery being read is partial or not and act accordingly, as partial deliveries expect additional updates as more frames comprising that IncomingDelivery arrive or the remote aborts the transfer.
        Specified by:
        deliveryReadHandler in interface Receiver
        Parameters:
        handler - The handler that will be invoked when Transfer frames arrive on this receiver link.
        Returns:
        this receiver
      • deliveryStateUpdatedHandler

        public Receiver deliveryStateUpdatedHandler​(EventHandler<IncomingDelivery> handler)
        Description copied from interface: Receiver
        Handler for updates to the remote state of incoming deliveries that have previously been received.

        Remote state updates for an IncomingDelivery can happen when the remote settles a complete IncomingDelivery or otherwise modifies the delivery outcome and the user needs to act on those changes such as a spontaneous update to the DeliveryState.

        Specified by:
        deliveryStateUpdatedHandler in interface Receiver
        Parameters:
        handler - The handler that will be invoked when a new remote state update for an IncomingDelivery arrives on this link.
        Returns:
        this receiver
      • creditStateUpdateHandler

        public Receiver creditStateUpdateHandler​(EventHandler<Receiver> handler)
        Description copied from interface: Link
        Handler for link credit updates that occur after a remote Flow arrives.
        Specified by:
        creditStateUpdateHandler in interface Link<Receiver>
        Parameters:
        handler - An event handler that will be signaled when the link credit is updated by a remote flow.
        Returns:
        the Link for chaining.