Package org.apache.qpid.protonj2.engine
Interface Sender
- All Known Implementing Classes:
ProtonSender
AMQP Sender API
-
Method Summary
Modifier and TypeMethodDescriptioncurrent()
Gets the currentOutgoingDelivery
for thisSender
if one is available.Handler for updates for deliveries that have previously been sent.disposition
(Predicate<OutgoingDelivery> filter, DeliveryState state, boolean settle) For each unsettled outgoing delivery that is pending in theSender
apply the given predicate and if it matches then apply the given delivery state and settled value to it.drained()
Called when theReceiver
has requested a drain of credit and the sender has sent all available messages.boolean
boolean
Checks if the sender has credit and the session window allows for any bytes to be written currently.next()
When there has been no deliveries so far or the current delivery has reached a complete state this method updates the current delivery to a new instance and returns that value.setDeliveryTagGenerator
(DeliveryTagGenerator generator) Configures aDeliveryTagGenerator
that will be used to create and set aDeliveryTag
value on each newOutgoingDelivery
that is created and returned from thenext()
method.settle
(Predicate<OutgoingDelivery> filter) For each unsettled outgoing delivery that is pending in theSender
apply the given predicate and if it matches then settle the delivery.Retrieves the list of unsettled deliveries sent from thisSender
.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 Details
-
drained
Sender drained()Called when theReceiver
has requested a drain of credit and the sender has sent all available messages.- Returns:
- this
Sender
instance. - Throws:
IllegalStateException
- if the link is not draining currently.
-
isSendable
boolean isSendable()Checks if the sender has credit and the session window allows for any bytes to be written currently.- Returns:
- true if the link has credit and the session window allows for any bytes to be written.
-
current
OutgoingDelivery current()Gets the currentOutgoingDelivery
for thisSender
if one is available.The sender only tracks a current delivery in the case that the next method has bee called and if any bytes are written to the delivery using the streaming based API
OutgoingDelivery.streamBytes(ProtonBuffer)
which allows for later writing of additional bytes to the delivery. Once the methodOutgoingDelivery.writeBytes(ProtonBuffer)
is called the finalTransfer
is written indicating that the delivery is complete and the current delivery value is reset. An outgoing delivery that is being streamed may also be completed by calling theOutgoingDelivery.abort()
method.- Returns:
- the current active outgoing delivery or null if there is no current delivery.
-
next
OutgoingDelivery next()When there has been no deliveries so far or the current delivery has reached a complete state this method updates the current delivery to a new instance and returns that value. If the currentOutgoingDelivery
has not been completed by either calling theOutgoingDelivery.writeBytes(ProtonBuffer)
or theOutgoingDelivery.abort()
method then this method will throw an exception to indicate the sender state cannot allow a new delivery to be started.- Returns:
- a new delivery instance unless the current delivery is not complete.
- Throws:
IllegalStateException
- if the current delivery has not been marked complete.
-
disposition
For each unsettled outgoing delivery that is pending in theSender
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
Sender
instance.
-
settle
For each unsettled outgoing delivery that is pending in theSender
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
Sender
instance.
-
unsettled
Collection<OutgoingDelivery> unsettled()Retrieves the list of unsettled deliveries sent from thisSender
. The deliveries in theCollection
cannot be written to but can have their settled state and disposition updated. Only when thisSender
settles on its end are theOutgoingDelivery
instances removed from the unsettledCollection
. 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 collection if no pending deliveries are outstanding.
-
hasUnsettled
boolean hasUnsettled()- Returns:
- true if there are unsettled deliveries for this
Sender
link.
-
setDeliveryTagGenerator
Configures aDeliveryTagGenerator
that will be used to create and set aDeliveryTag
value on each newOutgoingDelivery
that is created and returned from thenext()
method.- Parameters:
generator
- TheDeliveryTagGenerator
to use to create automaticDeliveryTag
values.- Returns:
- this
Sender
instance.
-
getDeliveryTagGenerator
DeliveryTagGenerator getDeliveryTagGenerator()- Returns:
- the currently configured
DeliveryTagGenerator
for thisSender
.
-
deliveryStateUpdatedHandler
Handler for updates for deliveries that have previously been sent. Updates can happen when the remote settles or otherwise modifies the delivery and the user needs to act on those changes.- Parameters:
handler
- The handler that will be invoked when a new update delivery arrives on this link.- Returns:
- this
Sender
instance.
-