Class ClientStreamDelivery
- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientStreamDelivery
-
- All Implemented Interfaces:
Delivery
,StreamDelivery
public final class ClientStreamDelivery extends java.lang.Object implements StreamDelivery
AStreamDelivery
implementation that provides the mechanics of reading message types from an incoming split framed transfer.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
aborted()
Check if theStreamDelivery
has been marked as aborted by the remote sender.StreamDelivery
accept()
Accepts and settles the delivery.java.util.Map<java.lang.String,java.lang.Object>
annotations()
Decodes theDelivery
payload and returns aMap
containing a copy of any associatedDeliveryAnnotations
that were transmitted with theMessage
payload of thisDelivery
.boolean
completed()
Check if theStreamDelivery
has been marked as complete by the remote sender.StreamDelivery
disposition(DeliveryState state, boolean settle)
Updates the DeliveryState, and optionally settle the delivery as well.ClientStreamReceiverMessage
message()
int
messageFormat()
Gets the message format for the current delivery.StreamDelivery
modified(boolean deliveryFailed, boolean undeliverableHere)
Modifies and settles the delivery.java.io.InputStream
rawInputStream()
Create and return anInputStream
that reads the raw payload bytes of the givenDelivery
.ClientStreamReceiver
receiver()
StreamDelivery
reject(java.lang.String condition, java.lang.String description)
Rejects and settles the delivery, sending supplied error information along with the rejection.StreamDelivery
release()
Releases and settles the delivery.boolean
remoteSettled()
Gets whether the delivery was settled by the remote peer yet.DeliveryState
remoteState()
Gets the current remote state for the delivery.StreamDelivery
settle()
Settles the delivery locally.boolean
settled()
DeliveryState
state()
Gets the current local state for the delivery.
-
-
-
Method Detail
-
receiver
public ClientStreamReceiver receiver()
- Specified by:
receiver
in interfaceDelivery
- Specified by:
receiver
in interfaceStreamDelivery
- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
.
-
aborted
public boolean aborted()
Description copied from interface:StreamDelivery
Check if theStreamDelivery
has been marked as aborted by the remote sender.- Specified by:
aborted
in interfaceStreamDelivery
- Returns:
- true if this context has been marked as aborted previously.
-
completed
public boolean completed()
Description copied from interface:StreamDelivery
Check if theStreamDelivery
has been marked as complete by the remote sender.- Specified by:
completed
in interfaceStreamDelivery
- Returns:
- true if this context has been marked as being the complete.
-
messageFormat
public int messageFormat()
Description copied from interface:Delivery
Gets the message format for the current delivery.- Specified by:
messageFormat
in interfaceDelivery
- Returns:
- the message format
-
message
public ClientStreamReceiverMessage message() throws ClientException
Description copied from interface:StreamDelivery
Decode theDelivery
payload and return anMessage
object.If the incoming message carried any delivery annotations they can be accessed via the
Delivery.annotations()
method. Re-sending the returned message will not also send the incoming delivery annotations, the sender must include them in theSender.send(Message, Map)
call if they are to be forwarded onto the next recipient.Calling this message claims the payload of the delivery for the returned
Message
and excludes use of theDelivery.rawInputStream()
method of theDelivery
object. Calling theDelivery.rawInputStream()
method after calling this method throwsClientIllegalStateException
.- Specified by:
message
in interfaceDelivery
- Specified by:
message
in interfaceStreamDelivery
- Returns:
- a
StreamReceiverMessage
instance that can be used to read the incoming message stream. - Throws:
ClientException
- if an error occurs while decoding the payload.
-
annotations
public java.util.Map<java.lang.String,java.lang.Object> annotations() throws ClientException
Description copied from interface:Delivery
Decodes theDelivery
payload and returns aMap
containing a copy of any associatedDeliveryAnnotations
that were transmitted with theMessage
payload of thisDelivery
.Calling this message claims the payload of the delivery for the returned
Map
and the decodedMessage
that can be accessed via theDelivery.message()
method and excludes use of theDelivery.rawInputStream()
method of theDelivery
object. Calling theDelivery.rawInputStream()
method after calling this method throwsClientIllegalStateException
.- Specified by:
annotations
in interfaceDelivery
- Returns:
- copy of the delivery annotations that were transmitted with the
Message
payload. - Throws:
ClientException
- if an error occurs while decoding the payload.
-
rawInputStream
public java.io.InputStream rawInputStream() throws ClientException
Description copied from interface:Delivery
Create and return anInputStream
that reads the raw payload bytes of the givenDelivery
.Calling this method claims the payload of the delivery for the returned
InputStream
and excludes use of theDelivery.message()
andDelivery.annotations()
methods of theDelivery
object. Closing the returned input stream discards any unread bytes from the delivery payload. Calling theDelivery.message()
orDelivery.annotations()
methods after calling this method throwsClientIllegalStateException
.- Specified by:
rawInputStream
in interfaceDelivery
- Returns:
- an
InputStream
instance that can be used to read the raw delivery payload. - Throws:
ClientException
- if an error occurs while decoding the payload.
-
accept
public StreamDelivery accept() throws ClientException
Description copied from interface:StreamDelivery
Accepts and settles the delivery.- Specified by:
accept
in interfaceDelivery
- Specified by:
accept
in interfaceStreamDelivery
- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
release
public StreamDelivery release() throws ClientException
Description copied from interface:StreamDelivery
Releases and settles the delivery.- Specified by:
release
in interfaceDelivery
- Specified by:
release
in interfaceStreamDelivery
- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
reject
public StreamDelivery reject(java.lang.String condition, java.lang.String description) throws ClientException
Description copied from interface:StreamDelivery
Rejects and settles the delivery, sending supplied error information along with the rejection.- Specified by:
reject
in interfaceDelivery
- Specified by:
reject
in interfaceStreamDelivery
- Parameters:
condition
- The error condition value to supply with the rejection.description
- The error description value to supply with the rejection.- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
modified
public StreamDelivery modified(boolean deliveryFailed, boolean undeliverableHere) throws ClientException
Description copied from interface:StreamDelivery
Modifies and settles the delivery.- Specified by:
modified
in interfaceDelivery
- Specified by:
modified
in interfaceStreamDelivery
- Parameters:
deliveryFailed
- Indicates if the modified delivery failed.undeliverableHere
- Indicates if the modified delivery should not be returned here again.- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
disposition
public StreamDelivery disposition(DeliveryState state, boolean settle) throws ClientException
Description copied from interface:StreamDelivery
Updates the DeliveryState, and optionally settle the delivery as well.- Specified by:
disposition
in interfaceDelivery
- Specified by:
disposition
in interfaceStreamDelivery
- Parameters:
state
- the delivery state to applysettle
- whether toDelivery.settle()
the delivery at the same time- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
settle
public StreamDelivery settle() throws ClientException
Description copied from interface:StreamDelivery
Settles the delivery locally.- Specified by:
settle
in interfaceDelivery
- Specified by:
settle
in interfaceStreamDelivery
- Returns:
- the
StreamReceiver
that originated thisStreamDelivery
. - Throws:
ClientException
- if an error occurs while sending the disposition
-
state
public DeliveryState state()
Description copied from interface:Delivery
Gets the current local state for the delivery.
-
settled
public boolean settled()
-
remoteState
public DeliveryState remoteState()
Description copied from interface:Delivery
Gets the current remote state for the delivery.- Specified by:
remoteState
in interfaceDelivery
- Returns:
- the remote delivery state
-
remoteSettled
public boolean remoteSettled()
Description copied from interface:Delivery
Gets whether the delivery was settled by the remote peer yet.- Specified by:
remoteSettled
in interfaceDelivery
- Returns:
- whether the delivery is remotely settled
-
-