Class ProtonOutgoingDelivery
- All Implemented Interfaces:
OutgoingDelivery
-
Constructor Summary
ConstructorDescriptionCreates an empty outgoing delivery instance that is owned by the givenProtonSender
instance. -
Method Summary
Modifier and TypeMethodDescriptionabort()
Aborts the outgoing delivery if not already settled.Handler for updates to the remote state of outgoing deliveries that have begun transferring frames.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> T
getLinkedResource
(Class<T> typeClass) Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.int
Gets the message-format for this Delivery, representing the 32bit value using an int.getState()
getTag()
int
Returns the total number of transfer frames that have occurred for the givenOutgoingDelivery
.boolean
boolean
Check for whether the delivery is still partial.boolean
boolean
setLinkedResource
(Object resource) Links a given resource to thisEndpoint
.setMessageFormat
(int messageFormat) Sets the message-format for this Delivery, representing the 32bit value using an integer value.setTag
(byte[] deliveryTag) Sets the delivery tag to assign to this outgoing delivery from the given byte array.setTag
(DeliveryTag deliveryTag) Sets theDeliveryTag
to assign to this outgoing delivery.settle()
Settles this delivery if not already settled.streamBytes
(ProtonBuffer buffer) Write the given bytes as a portion of the payload of this delivery, additional bytes can be streamed until the stream complete flag is set to true on a call toOutgoingDelivery.streamBytes(ProtonBuffer, boolean)
or a call toOutgoingDelivery.writeBytes(ProtonBuffer)
is made.streamBytes
(ProtonBuffer buffer, boolean complete) Write the given bytes as a portion of the payload of this delivery, additional bytes can be streamed until the stream complete flag is set to true on a call toOutgoingDelivery.streamBytes(ProtonBuffer, boolean)
and the buffer contents on that send are fully written.toString()
writeBytes
(ProtonBuffer buffer) Write the given bytes as the payload of this delivery, no additional writes can occur on this delivery if the write succeeds in sending all of the given bytes.
-
Constructor Details
-
ProtonOutgoingDelivery
Creates an empty outgoing delivery instance that is owned by the givenProtonSender
instance.- Parameters:
link
- theSender
link that owns this outgoing delivery.
-
-
Method Details
-
getLink
- Specified by:
getLink
in interfaceOutgoingDelivery
- Returns:
- the link that this
OutgoingDelivery
is bound to.
-
getAttachments
- Specified by:
getAttachments
in interfaceOutgoingDelivery
- Returns:
- the
Attachments
instance that is associated with thisOutgoingDelivery
-
setLinkedResource
Description copied from interface:OutgoingDelivery
Links a given resource to thisEndpoint
.- Specified by:
setLinkedResource
in interfaceOutgoingDelivery
- Parameters:
resource
- The resource to link to thisEndpoint
.- Returns:
- this
OutgoingDelivery
instance.
-
getLinkedResource
public <T> T getLinkedResource()- Specified by:
getLinkedResource
in interfaceOutgoingDelivery
- Type Parameters:
T
- The type that the linked resource should be cast to on return.- Returns:
- the user set linked resource for this
Endpoint
instance.
-
getLinkedResource
Description copied from interface:OutgoingDelivery
Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.- Specified by:
getLinkedResource
in interfaceOutgoingDelivery
- 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:
getTag
in interfaceOutgoingDelivery
- Returns:
- the
DeliveryTag
assigned to this Delivery.
-
setTag
Description copied from interface:OutgoingDelivery
Sets the delivery tag to assign to this outgoing delivery from the given byte array.- Specified by:
setTag
in interfaceOutgoingDelivery
- Parameters:
deliveryTag
- a byte array containing the delivery tag to assign to thisOutgoingDelivery
- Returns:
- this
OutgoingDelivery
instance.
-
setTag
Description copied from interface:OutgoingDelivery
Sets theDeliveryTag
to assign to this outgoing delivery.- Specified by:
setTag
in interfaceOutgoingDelivery
- Parameters:
deliveryTag
- a byte array containing the delivery tag to assign to thisOutgoingDelivery
- Returns:
- this
OutgoingDelivery
instance.
-
getState
- Specified by:
getState
in interfaceOutgoingDelivery
- Returns:
- the
DeliveryState
at the local side of this Delivery.
-
getRemoteState
- Specified by:
getRemoteState
in interfaceOutgoingDelivery
- Returns:
- the
DeliveryState
at the remote side of this Delivery.
-
getMessageFormat
public int getMessageFormat()Description copied from interface:OutgoingDelivery
Gets 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:
getMessageFormat
in interfaceOutgoingDelivery
- Returns:
- the message-format for this Delivery.
-
setMessageFormat
Description copied from interface:OutgoingDelivery
Sets the message-format for this Delivery, representing the 32bit value using an integer value. The message format can only be set@Override prior to the firstTransfer
of delivery payload having been written. If one of the delivery write methods is called prior to the message format being set then it defaults to the AMQP default format of zero.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:
setMessageFormat
in interfaceOutgoingDelivery
- Parameters:
messageFormat
- the message format- Returns:
- this
OutgoingDelivery
instance.
-
isPartial
public boolean isPartial()Description copied from interface:OutgoingDelivery
Check 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
aborted
delivery 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:
isPartial
in interfaceOutgoingDelivery
- Returns:
- true if the delivery is partial
- See Also:
-
isAborted
public boolean isAborted()- Specified by:
isAborted
in interfaceOutgoingDelivery
- Returns:
- true if the delivery has been aborted.
-
isSettled
public boolean isSettled()- Specified by:
isSettled
in interfaceOutgoingDelivery
- Returns:
- true if the delivery has been settled locally.
-
isRemotelySettled
public boolean isRemotelySettled()- Specified by:
isRemotelySettled
in interfaceOutgoingDelivery
- Returns:
- true if the delivery has been settled by the remote.
-
disposition
Description copied from interface:OutgoingDelivery
updates the state of the delivery- Specified by:
disposition
in interfaceOutgoingDelivery
- Parameters:
state
- the new delivery state- Returns:
- this
OutgoingDelivery
instance.
-
disposition
Description copied from interface:OutgoingDelivery
Update the delivery with the given disposition if not locally settled and optionally settles the delivery if not already settled.The action taken by this method depends on the state of the
OutgoingDelivery
at the time it is called.If there has yet to be any writes from this delivery the delivery state and settlement value is cached and applied to the first (or only) write of payload from this delivery. If however a write has already been performed than this method result in a
Disposition
frame being sent to the remote with the given delivery state and settlement value. Once the delivery is marked as settled any future call to this method will do nothing if the requested disposition and settlement is the same however if a new state is applied which cannot be conveyed due to having already locally settling theOutgoingDelivery
than anIllegalStateException
is thrown to indicate that request is not valid.- Specified by:
disposition
in interfaceOutgoingDelivery
- Parameters:
state
- the new delivery statesettle
- if true the delivery is settled.- Returns:
- this
OutgoingDelivery
instance.
-
settle
Description copied from interface:OutgoingDelivery
Settles this delivery if not already settled. Once settled locally no further updates to the delivery state can be applied. If called prior to the first write of payload bytes the settlement state is cached and transmitted within the firstTransfer
frame of thisOutgoingDelivery
.- Specified by:
settle
in interfaceOutgoingDelivery
- Returns:
- this
OutgoingDelivery
instance.
-
writeBytes
Description copied from interface:OutgoingDelivery
Write the given bytes as the payload of this delivery, no additional writes can occur on this delivery if the write succeeds in sending all of the given bytes.When called the provided buffer is treated as containing the entirety of the transfer payload and the Transfer(s) that result from this call will result in a final Transfer frame whose more flag is set to false which tells the remote that no additional data will be sent for this
Transfer
. TheSender
will output as much of the buffer as possible within the constraints of both the link credit and the current capacity of the parentSession
.The caller must check that all bytes were written and if not they should await updates from the
Link.creditStateUpdateHandler(EventHandler)
that indicate that theSender.isSendable()
has become true again or the caller should checkSender.isSendable()
periodically until it becomes true once again.- Specified by:
writeBytes
in interfaceOutgoingDelivery
- Parameters:
buffer
- The buffer whose contents should be sent.- Returns:
- this
OutgoingDelivery
instance.
-
streamBytes
Description copied from interface:OutgoingDelivery
Write the given bytes as a portion of the payload of this delivery, additional bytes can be streamed until the stream complete flag is set to true on a call toOutgoingDelivery.streamBytes(ProtonBuffer, boolean)
or a call toOutgoingDelivery.writeBytes(ProtonBuffer)
is made.The
Sender
will output as much of the buffer as possible within the constraints of both the link credit and the current capacity of the parentSession
. The caller must check that all bytes were0 written and if not they should await updates from theLink.creditStateUpdateHandler(EventHandler)
that indicate that theSender.isSendable()
has become true again or the caller should checkSender.isSendable()
periodically until it becomes true once again.This method is the same as calling
OutgoingDelivery.streamBytes(ProtonBuffer, boolean)
with the complete value set to false.- Specified by:
streamBytes
in interfaceOutgoingDelivery
- Parameters:
buffer
- The buffer whose contents should be sent.- Returns:
- this
OutgoingDelivery
instance.
-
streamBytes
Description copied from interface:OutgoingDelivery
Write the given bytes as a portion of the payload of this delivery, additional bytes can be streamed until the stream complete flag is set to true on a call toOutgoingDelivery.streamBytes(ProtonBuffer, boolean)
and the buffer contents on that send are fully written.The
Sender
will output as much of the buffer as possible within the constraints of both the link credit and the current capacity of the parentSession
. The caller must check that all bytes were0 written and if not they should await updates from theLink.creditStateUpdateHandler(EventHandler)
that indicate that theSender.isSendable()
has become true again or the caller should checkSender.isSendable()
periodically until it becomes true once again.- Specified by:
streamBytes
in interfaceOutgoingDelivery
- Parameters:
buffer
- The buffer whose contents should be sent.complete
- When true the delivery is marked complete and no further bytes can be written.- Returns:
- this
OutgoingDelivery
instance.
-
abort
Description copied from interface:OutgoingDelivery
Aborts the outgoing delivery if not already settled.- Specified by:
abort
in interfaceOutgoingDelivery
- Returns:
- this delivery.
-
deliveryStateUpdatedHandler
Description copied from interface:OutgoingDelivery
Handler for updates to the remote state of outgoing deliveries that have begun transferring frames.Remote state updates for an
OutgoingDelivery
can happen when the remote settles a completeOutgoingDelivery
or otherwise modifies the delivery outcome and the user needs to act on those changes such as a spontaneous update to theDeliveryState
. If the initialTransfer
of an outgoing delivery already indicates settlement then this handler will never be called.- Specified by:
deliveryStateUpdatedHandler
in interfaceOutgoingDelivery
- Parameters:
handler
- The handler that will be invoked when a new remote state update for anOutgoingDelivery
arrives on this link.- Returns:
- this
OutgoingDelivery
instance.
-
toString
-
getTransferCount
public int getTransferCount()Description copied from interface:OutgoingDelivery
Returns the total number of transfer frames that have occurred for the givenOutgoingDelivery
. If theOutgoingDelivery
has yet to have any of its write methods called this value will read zero. Aborting a transfer after anyTransfer
frames have been written will not result in an addition recordedTransfer
write.- Specified by:
getTransferCount
in interfaceOutgoingDelivery
- Returns:
- the number of
Transfer
frames that thisOutgoingDelivery
has initiated.
-