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
AStreamDeliveryimplementation 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 booleanaborted()Check if theStreamDeliveryhas been marked as aborted by the remote sender.StreamDeliveryaccept()Accepts and settles the delivery.java.util.Map<java.lang.String,java.lang.Object>annotations()Decodes theDeliverypayload and returns aMapcontaining a copy of any associatedDeliveryAnnotationsthat were transmitted with theMessagepayload of thisDelivery.booleancompleted()Check if theStreamDeliveryhas been marked as complete by the remote sender.StreamDeliverydisposition(DeliveryState state, boolean settle)Updates the DeliveryState, and optionally settle the delivery as well.ClientStreamReceiverMessagemessage()intmessageFormat()Gets the message format for the current delivery.StreamDeliverymodified(boolean deliveryFailed, boolean undeliverableHere)Modifies and settles the delivery.java.io.InputStreamrawInputStream()Create and return anInputStreamthat reads the raw payload bytes of the givenDelivery.ClientStreamReceiverreceiver()StreamDeliveryreject(java.lang.String condition, java.lang.String description)Rejects and settles the delivery, sending supplied error information along with the rejection.StreamDeliveryrelease()Releases and settles the delivery.booleanremoteSettled()Gets whether the delivery was settled by the remote peer yet.DeliveryStateremoteState()Gets the current remote state for the delivery.StreamDeliverysettle()Settles the delivery locally.booleansettled()DeliveryStatestate()Gets the current local state for the delivery.
-
-
-
Method Detail
-
receiver
public ClientStreamReceiver receiver()
- Specified by:
receiverin interfaceDelivery- Specified by:
receiverin interfaceStreamDelivery- Returns:
- the
StreamReceiverthat originated thisStreamDelivery.
-
aborted
public boolean aborted()
Description copied from interface:StreamDeliveryCheck if theStreamDeliveryhas been marked as aborted by the remote sender.- Specified by:
abortedin interfaceStreamDelivery- Returns:
- true if this context has been marked as aborted previously.
-
completed
public boolean completed()
Description copied from interface:StreamDeliveryCheck if theStreamDeliveryhas been marked as complete by the remote sender.- Specified by:
completedin interfaceStreamDelivery- Returns:
- true if this context has been marked as being the complete.
-
messageFormat
public int messageFormat()
Description copied from interface:DeliveryGets the message format for the current delivery.- Specified by:
messageFormatin interfaceDelivery- Returns:
- the message format
-
message
public ClientStreamReceiverMessage message() throws ClientException
Description copied from interface:StreamDeliveryDecode theDeliverypayload and return anMessageobject.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
Messageand excludes use of theDelivery.rawInputStream()method of theDeliveryobject. Calling theDelivery.rawInputStream()method after calling this method throwsClientIllegalStateException.- Specified by:
messagein interfaceDelivery- Specified by:
messagein interfaceStreamDelivery- Returns:
- a
StreamReceiverMessageinstance 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 ClientExceptionDescription copied from interface:DeliveryDecodes theDeliverypayload and returns aMapcontaining a copy of any associatedDeliveryAnnotationsthat were transmitted with theMessagepayload of thisDelivery.Calling this message claims the payload of the delivery for the returned
Mapand the decodedMessagethat can be accessed via theDelivery.message()method and excludes use of theDelivery.rawInputStream()method of theDeliveryobject. Calling theDelivery.rawInputStream()method after calling this method throwsClientIllegalStateException.- Specified by:
annotationsin interfaceDelivery- Returns:
- copy of the delivery annotations that were transmitted with the
Messagepayload. - Throws:
ClientException- if an error occurs while decoding the payload.
-
rawInputStream
public java.io.InputStream rawInputStream() throws ClientExceptionDescription copied from interface:DeliveryCreate and return anInputStreamthat reads the raw payload bytes of the givenDelivery.Calling this method claims the payload of the delivery for the returned
InputStreamand excludes use of theDelivery.message()andDelivery.annotations()methods of theDeliveryobject. 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:
rawInputStreamin interfaceDelivery- Returns:
- an
InputStreaminstance 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:StreamDeliveryAccepts and settles the delivery.- Specified by:
acceptin interfaceDelivery- Specified by:
acceptin interfaceStreamDelivery- Returns:
- the
StreamReceiverthat originated thisStreamDelivery. - Throws:
ClientException- if an error occurs while sending the disposition
-
release
public StreamDelivery release() throws ClientException
Description copied from interface:StreamDeliveryReleases and settles the delivery.- Specified by:
releasein interfaceDelivery- Specified by:
releasein interfaceStreamDelivery- Returns:
- the
StreamReceiverthat 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:StreamDeliveryRejects and settles the delivery, sending supplied error information along with the rejection.- Specified by:
rejectin interfaceDelivery- Specified by:
rejectin interfaceStreamDelivery- Parameters:
condition- The error condition value to supply with the rejection.description- The error description value to supply with the rejection.- Returns:
- the
StreamReceiverthat 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:StreamDeliveryModifies and settles the delivery.- Specified by:
modifiedin interfaceDelivery- Specified by:
modifiedin interfaceStreamDelivery- Parameters:
deliveryFailed- Indicates if the modified delivery failed.undeliverableHere- Indicates if the modified delivery should not be returned here again.- Returns:
- the
StreamReceiverthat 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:StreamDeliveryUpdates the DeliveryState, and optionally settle the delivery as well.- Specified by:
dispositionin interfaceDelivery- Specified by:
dispositionin interfaceStreamDelivery- Parameters:
state- the delivery state to applysettle- whether toDelivery.settle()the delivery at the same time- Returns:
- the
StreamReceiverthat originated thisStreamDelivery. - Throws:
ClientException- if an error occurs while sending the disposition
-
settle
public StreamDelivery settle() throws ClientException
Description copied from interface:StreamDeliverySettles the delivery locally.- Specified by:
settlein interfaceDelivery- Specified by:
settlein interfaceStreamDelivery- Returns:
- the
StreamReceiverthat originated thisStreamDelivery. - Throws:
ClientException- if an error occurs while sending the disposition
-
state
public DeliveryState state()
Description copied from interface:DeliveryGets the current local state for the delivery.
-
settled
public boolean settled()
-
remoteState
public DeliveryState remoteState()
Description copied from interface:DeliveryGets the current remote state for the delivery.- Specified by:
remoteStatein interfaceDelivery- Returns:
- the remote delivery state
-
remoteSettled
public boolean remoteSettled()
Description copied from interface:DeliveryGets whether the delivery was settled by the remote peer yet.- Specified by:
remoteSettledin interfaceDelivery- Returns:
- whether the delivery is remotely settled
-
-