Class ProtonIncomingDelivery
- All Implemented Interfaces:
IncomingDelivery
-
Constructor Summary
ConstructorsConstructorDescriptionProtonIncomingDelivery(ProtonReceiver link, long deliveryId, DeliveryTag deliveryTag) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes currently available for reading form this delivery, which may not be complete yet.Marks all available bytes as being claimed by the caller meaning that available byte count value can be returned to the session which can expand the session incoming window to allow more bytes to be sent from the remote peer.Handler for aborted deliveries that is called if this delivery is aborted by theSender.deliveryReadHandler(EventHandler<IncomingDelivery> handler) Handler for updates to the remote state of incoming deliveries that have previously been received.disposition(DeliveryState state) updates the state of the deliverydisposition(DeliveryState state, boolean settle) Update the delivery with the given disposition if not locally settled and optionally settles the delivery if not already settled.getLink()<T> T<T> TgetLinkedResource(Class<T> typeClass) Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.intGets the message-format for this Delivery, representing the 32bit value using an int.getState()getTag()intReturns the total number of transfer frames that have occurred for the givenIncomingDelivery.booleanbooleanCheck for whether the delivery is still partial.booleanbooleanreadAll()Returns the current read buffer without copying it effectively consuming all currently available bytes from this delivery.readBytes(byte[] array, int offset, int length) Reads bytes from this delivery and writes them into the destination array starting at the given offset and continuing for the specified length reducing the available bytes by the value of the number of bytes written to the target.readBytes(ProtonBuffer buffer) Reads bytes from this delivery and writes them into the destination ProtonBuffer reducing the available bytes by the value of the number of bytes written to the target.Configures a default DeliveryState to be used if a received delivery is settled/freed without any disposition state having been previously applied.setLinkedResource(Object resource) Links a given resource to thisIncomingDelivery.settle()Settles this delivery locally, transmitting aDispositionframe to the remote if the remote has not already settled the delivery.toString()
-
Constructor Details
-
ProtonIncomingDelivery
- Parameters:
link- The link that this delivery is associated withdeliveryId- The Delivery Id that is assigned to this delivery.deliveryTag- The delivery tag assigned to this delivery
-
-
Method Details
-
getLink
- Specified by:
getLinkin interfaceIncomingDelivery- Returns:
- the link that this
IncomingDeliveryis bound to.
-
getAttachments
- Specified by:
getAttachmentsin interfaceIncomingDelivery- Returns:
- the
Attachmentsinstance that is associated with thisIncomingDelivery
-
setLinkedResource
Description copied from interface:IncomingDeliveryLinks a given resource to thisIncomingDelivery.- Specified by:
setLinkedResourcein interfaceIncomingDelivery- Parameters:
resource- The resource to link to thisIncomingDelivery.- Returns:
- this
IncomingDeliveryinstance.
-
getLinkedResource
public <T> T getLinkedResource()- Specified by:
getLinkedResourcein interfaceIncomingDelivery- Type Parameters:
T- The type that the linked resource should be cast to on return.- Returns:
- the user set linked resource for this
Endpointinstance.
-
getLinkedResource
Description copied from interface:IncomingDeliveryGets the linked resource (if set) and returns it using the type information provided to cast the returned value.- Specified by:
getLinkedResourcein interfaceIncomingDelivery- Type Parameters:
T- The type to cast the linked resource to if one is set.- Parameters:
typeClass- the type's Class which is used for casting the returned value.- Returns:
- the user set linked resource for this Context instance.
-
getTag
- Specified by:
getTagin interfaceIncomingDelivery- Returns:
- the
DeliveryTagassigned to this Delivery.
-
getState
- Specified by:
getStatein interfaceIncomingDelivery- Returns:
- the
DeliveryStateat the local side of this Delivery.
-
getRemoteState
- Specified by:
getRemoteStatein interfaceIncomingDelivery- Returns:
- the
DeliveryStateat the remote side of this Delivery.
-
getMessageFormat
public int getMessageFormat()Description copied from interface:IncomingDeliveryGets the message-format for this Delivery, representing the 32bit value using an int.The default value is 0 as per the message format defined in the core AMQP 1.0 specification.
See the following for more details:
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT- Specified by:
getMessageFormatin interfaceIncomingDelivery- Returns:
- the message-format for this Delivery.
-
isPartial
public boolean isPartial()Description copied from interface:IncomingDeliveryCheck for whether the delivery is still partial.For a receiving Delivery, this means the delivery does not hold a complete message payload as all the content hasn't been received yet. Note that an
aborteddelivery will also be considered partial and the full payload won't be received.For a sending Delivery, this means that the application has not marked the delivery as complete yet.
- Specified by:
isPartialin interfaceIncomingDelivery- Returns:
- true if the delivery is partial
- See Also:
-
isAborted
public boolean isAborted()- Specified by:
isAbortedin interfaceIncomingDelivery- Returns:
- true if the delivery has been aborted.
-
isSettled
public boolean isSettled()- Specified by:
isSettledin interfaceIncomingDelivery- Returns:
- true if the delivery has been settled locally.
-
isRemotelySettled
public boolean isRemotelySettled()- Specified by:
isRemotelySettledin interfaceIncomingDelivery- Returns:
- true if the delivery has been settled by the remote.
-
setDefaultDeliveryState
Description copied from interface:IncomingDeliveryConfigures a default DeliveryState to be used if a received delivery is settled/freed without any disposition state having been previously applied.- Specified by:
setDefaultDeliveryStatein interfaceIncomingDelivery- Parameters:
state- the default delivery state- Returns:
- this
IncomingDeliveryinstance.
-
getDefaultDeliveryState
- Specified by:
getDefaultDeliveryStatein interfaceIncomingDelivery- Returns:
- the default delivery state for this delivery
-
disposition
Description copied from interface:IncomingDeliveryupdates the state of the delivery- Specified by:
dispositionin interfaceIncomingDelivery- Parameters:
state- the new delivery state- Returns:
- this
IncomingDeliveryinstance.
-
disposition
Description copied from interface:IncomingDeliveryUpdate the delivery with the given disposition if not locally settled and optionally settles the delivery if not already settled.Applies the given delivery state and local settlement value to this delivery writing a new
Dispositionframe if the remote has not already settled the delivery. Once locally settled no additional updates to the localDeliveryStatecan be applied and if attempted anIllegalStateExceptionwill be thrown to indicate this is not possible.- Specified by:
dispositionin interfaceIncomingDelivery- Parameters:
state- the new delivery statesettle- if true the delivery is settled.- Returns:
- this
IncomingDeliveryinstance.
-
settle
Description copied from interface:IncomingDeliverySettles this delivery locally, transmitting aDispositionframe to the remote if the remote has not already settled the delivery. Once locally settled the delivery will not accept any additional updates to theDeliveryStatevia one of theIncomingDelivery.disposition(DeliveryState)orIncomingDelivery.disposition(DeliveryState, boolean)methods.- Specified by:
settlein interfaceIncomingDelivery- Returns:
- this
IncomingDeliveryinstance.
-
available
public int available()Description copied from interface:IncomingDeliveryReturns the number of bytes currently available for reading form this delivery, which may not be complete yet.Note that this value will change as bytes are received, and is in general not equal to the total length of a delivery, except the point where
IncomingDelivery.isPartial()returns false and no content has yet been received by the application.- Specified by:
availablein interfaceIncomingDelivery- Returns:
- the number of bytes currently available to read from this delivery.
-
readAll
Description copied from interface:IncomingDeliveryReturns the current read buffer without copying it effectively consuming all currently available bytes from this delivery. If no data is available then this method returnsnull.- Specified by:
readAllin interfaceIncomingDelivery- Returns:
- the currently available read bytes for this delivery.
-
readBytes
Description copied from interface:IncomingDeliveryReads bytes from this delivery and writes them into the destination ProtonBuffer reducing the available bytes by the value of the number of bytes written to the target. The number of bytes written will be the equal to the writable bytes of the target buffer. The write index of the target buffer will be incremented by the number of bytes written into it.- Specified by:
readBytesin interfaceIncomingDelivery- Parameters:
buffer- The target buffer that will be written into.- Returns:
- this
IncomingDeliveryinstance.
-
readBytes
Description copied from interface:IncomingDeliveryReads bytes from this delivery and writes them into the destination array starting at the given offset and continuing for the specified length reducing the available bytes by the value of the number of bytes written to the target.- Specified by:
readBytesin interfaceIncomingDelivery- Parameters:
array- The target buffer that will be written into.offset- The offset into the given array to begin writing.length- The number of bytes to write to the given array.- Returns:
- this
IncomingDeliveryinstance.
-
claimAvailableBytes
Description copied from interface:IncomingDeliveryMarks all available bytes as being claimed by the caller meaning that available byte count value can be returned to the session which can expand the session incoming window to allow more bytes to be sent from the remote peer.This method is useful in the case where the
Sessionhas been configured with a small incoming capacity and the receiver needs to expand the session window in order to read the entire contents of a delivery whose payload exceeds the configured session capacity. TheIncomingDeliveryimplementation will track the amount of claimed bytes and ensure that it never releases back more bytes to theSessionthan has actually been received as a whole which allows this method to be called with each incomingTransferframe of a large split framed delivery.- Specified by:
claimAvailableBytesin interfaceIncomingDelivery- Returns:
- this
IncomingDeliveryinstance.
-
deliveryReadHandler
Description copied from interface:IncomingDeliveryHandler for incoming deliveries that is called for each incomingTransferframe 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 thatIncomingDeliveryarrive or the remote aborts the transfer.This handler is useful in cases where an incoming delivery is split across many incoming
Transferframes either due to a large size or a small max frame size setting and the processing is handed off to some other resource other than theReceiverthat original handling the first transfer frame. If the initialTransfercarries the entire delivery payload then this event handler will never be called. Once set this event handler receiver all updates of incoming deliveryTransferframes which would otherwise have been sent to theReceiver.deliveryReadHandler(EventHandler)instance.- Specified by:
deliveryReadHandlerin interfaceIncomingDelivery- Parameters:
handler- The handler that will be invoked whenTransferframes arrive on this receiver link.- Returns:
- this
IncomingDeliveryinstance.
-
deliveryAbortedHandler
Description copied from interface:IncomingDeliveryHandler for aborted deliveries that is called if this delivery is aborted by theSender.This handler is an optional convenience handler that supplements the standard
IncomingDelivery.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 theReceiverwill call the registeredIncomingDelivery.deliveryAbortedHandler(EventHandler)if one is set.- Specified by:
deliveryAbortedHandlerin interfaceIncomingDelivery- Parameters:
handler- The handler that will be invoked whenTransferframes arrive on this receiver link.- Returns:
- this
IncomingDeliveryinstance.
-
deliveryStateUpdatedHandler
Description copied from interface:IncomingDeliveryHandler for updates to the remote state of incoming deliveries that have previously been received.Remote state updates for an
IncomingDeliverycan happen when the remote settles a completeIncomingDeliveryor otherwise modifies the delivery outcome and the user needs to act on those changes such as a spontaneous update to theDeliveryState. If the initialTransferof an incoming delivery already indicates settlement then this handler will never be called.- Specified by:
deliveryStateUpdatedHandlerin interfaceIncomingDelivery- Parameters:
handler- The handler that will be invoked when a new remote state update for anIncomingDeliveryarrives on this link.- Returns:
- this
IncomingDeliveryinstance.
-
getTransferCount
public int getTransferCount()Description copied from interface:IncomingDeliveryReturns the total number of transfer frames that have occurred for the givenIncomingDelivery.- Specified by:
getTransferCountin interfaceIncomingDelivery- Returns:
- the number of
Transferframes that thisOutgoingDeliveryhas initiated.
-
toString
-