Package org.apache.qpid.protonj2.engine
Interface Receiver
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Receiver
addCredit(int additionalCredit)
Adds the given amount of credit for theReceiver
.Receiver
deliveryAbortedHandler(EventHandler<IncomingDelivery> handler)
Handler for aborted deliveries that is called for each aborted in-progress delivery.Receiver
deliveryReadHandler(EventHandler<IncomingDelivery> handler)
Receiver
deliveryStateUpdatedHandler(EventHandler<IncomingDelivery> handler)
Handler for updates to the remote state of incoming deliveries that have previously been received.Receiver
disposition(Predicate<IncomingDelivery> filter, DeliveryState state, boolean settle)
For each unsettled outgoing delivery that is pending in theReceiver
apply the given predicate and if it matches then apply the given delivery state and settled value to it.boolean
drain()
Initiate a drain of all remaining credit of thisReceiver
link.boolean
drain(int credit)
Initiate a drain of the given credit from this thisReceiver
link.DeliveryState
getDefaultDeliveryState()
boolean
hasUnsettled()
Receiver
setDefaultDeliveryState(DeliveryState state)
Configures a default DeliveryState to be used if a received delivery is settled/freed without any disposition state having been previously applied.Receiver
settle(Predicate<IncomingDelivery> filter)
For each unsettled outgoing delivery that is pending in theReceiver
apply the given predicate and if it matches then settle the delivery.Collection<IncomingDelivery>
unsettled()
Retrieves the list of unsettled deliveries for thisReceiver
link which have yet to be settled on this end of the link.-
Methods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
close, closeHandler, engineShutdownHandler, getAttachments, getCondition, getDesiredCapabilities, getEngine, getLinkedResource, getLinkedResource, getOfferedCapabilities, getProperties, getRemoteCondition, getRemoteDesiredCapabilities, getRemoteOfferedCapabilities, getRemoteProperties, isLocallyClosed, isLocallyOpen, localCloseHandler, localOpenHandler, open, openHandler, setCondition, setDesiredCapabilities, setLinkedResource, setOfferedCapabilities, setProperties
-
Methods inherited from interface org.apache.qpid.protonj2.engine.Link
creditStateUpdateHandler, detach, detachHandler, getConnection, getCredit, getMaxMessageSize, getName, getParent, getReceiverSettleMode, getRemoteMaxMessageSize, getRemoteReceiverSettleMode, getRemoteSenderSettleMode, getRemoteSource, getRemoteState, getRemoteTarget, getRole, getSenderSettleMode, getSession, getSource, getState, getTarget, isDraining, isLocallyClosedOrDetached, isLocallyDetached, isReceiver, isRemotelyClosed, isRemotelyClosedOrDetached, isRemotelyDetached, isRemotelyOpen, isSender, localDetachHandler, parentEndpointClosedHandler, setMaxMessageSize, setReceiverSettleMode, setSenderSettleMode, setSource, setTarget, setTarget
-
-
-
-
Method Detail
-
addCredit
Receiver addCredit(int additionalCredit)
Adds the given amount of credit for theReceiver
.- Parameters:
additionalCredit
- the new amount of credits to add.- Returns:
- this
Receiver
- Throws:
IllegalArgumentException
- if the credit amount is negative.
-
drain
boolean drain()
Initiate a drain of all remaining credit of thisReceiver
link.- Returns:
- true if a drain was started or false if the link already had no credit to drain.
- Throws:
IllegalStateException
- if an existing drain attempt is incomplete.
-
drain
boolean drain(int credit)
Initiate a drain of the given credit from this thisReceiver
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.- Parameters:
credit
- 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.
- Throws:
IllegalStateException
- if an existing drain attempt is incomplete.IllegalArgumentException
- if the credit value given is less than the current value.
-
setDefaultDeliveryState
Receiver setDefaultDeliveryState(DeliveryState state)
Configures a default DeliveryState to be used if a received delivery is settled/freed without any disposition state having been previously applied.- Parameters:
state
- the default delivery state- Returns:
- this
Receiver
for chaining.
-
getDefaultDeliveryState
DeliveryState getDefaultDeliveryState()
- Returns:
- the default delivery state for this delivery
-
disposition
Receiver disposition(Predicate<IncomingDelivery> filter, DeliveryState state, boolean settle)
For each unsettled outgoing delivery that is pending in theReceiver
apply the given predicate and if it matches then apply the given delivery state and settled value to it.- Parameters:
filter
- The predicate to apply to each unsettled delivery to test for a match.state
- The newDeliveryState
to apply to any matching outgoing deliveries.settle
- Boolean indicating if the matching unsettled deliveries should be settled.- Returns:
- this
Receiver
for chaining
-
settle
Receiver settle(Predicate<IncomingDelivery> filter)
For each unsettled outgoing delivery that is pending in theReceiver
apply the given predicate and if it matches then settle the delivery.- Parameters:
filter
- The predicate to apply to each unsettled delivery to test for a match.- Returns:
- this
Receiver
for chaining
-
unsettled
Collection<IncomingDelivery> unsettled()
Retrieves the list of unsettled deliveries for thisReceiver
link which have yet to be settled on this end of the link. When theIncomingDelivery
is settled by the receiver the value will be removed from the collection. TheCollection
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.- Returns:
- a collection of unsettled deliveries or an empty list if no pending deliveries are outstanding.
-
hasUnsettled
boolean hasUnsettled()
- Returns:
- true if there are unsettled deliveries for this
Receiver
link.
-
deliveryReadHandler
Receiver deliveryReadHandler(EventHandler<IncomingDelivery> handler)
Handler for incoming deliveries that is called for each incomingTransfer
frame that comprises either one complete delivery or a chunk of a split framedTransfer
. 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 thatIncomingDelivery
arrive or the remote aborts the transfer.- Parameters:
handler
- The handler that will be invoked whenTransfer
frames arrive on this receiver link.- Returns:
- this receiver
-
deliveryAbortedHandler
Receiver deliveryAbortedHandler(EventHandler<IncomingDelivery> handler)
Handler for aborted deliveries that is called for each aborted in-progress delivery.This handler is an optional convenience handler that supplements the standard
deliveryReadHandler(EventHandler)
in cases where the users wishes to break out the processing of inbound delivery data from abort processing. If this handler is not set theReceiver
will call the registereddeliveryAbortedHandler(EventHandler)
if one is set.- Parameters:
handler
- The handler that will be invoked whenTransfer
frames arrive on this receiver link.- Returns:
- this receiver
-
deliveryStateUpdatedHandler
Receiver deliveryStateUpdatedHandler(EventHandler<IncomingDelivery> handler)
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 completeIncomingDelivery
or otherwise modifies the delivery outcome and the user needs to act on those changes such as a spontaneous update to theDeliveryState
.- Parameters:
handler
- The handler that will be invoked when a new remote state update for anIncomingDelivery
arrives on this link.- Returns:
- this receiver
-
-