Debian Codegraph @

proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java

raw
1 /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.proton.engine;
22
23 import org.apache.qpid.proton.amqp.transport.DeliveryState;
24
25 /**
26 * A delivery of a message on a particular link.
27 *
28 * Whilst a message is logically a long-lived object, a delivery is short-lived - it
29 * is only intended to be used by the application until it is settled and all its data has been read.
30 */
31 public interface Delivery extends Extendable
32 {
33
34 public byte[] getTag();
35
36 public Link getLink();
37
38 public DeliveryState getLocalState();
39
40 public DeliveryState getRemoteState();
41
42 /**
43 * updates the state of the delivery
44 *
45 * The new state may have no on-the-wire effect, if delivery settlement was already communicated to/from the peer.
46 *
47 * @param state the new delivery state
48 */
49 public void disposition(DeliveryState state);
50
51 /**
52 * Settles this delivery.
53 *
54 * Causes the delivery to be removed from the connection's work list (see {@link Connection#getWorkHead()}).
55 * If this delivery is its link's current delivery, the link's current delivery pointer is advanced.
56 */
57 public void settle();
58
59 /**
60 * Returns whether this delivery has been settled.
61 *
62 * TODO proton-j and proton-c return the local and remote statuses respectively. Resolve this ambiguity.
63 *
64 * @see #settle()
65 */
66 public boolean isSettled();
67
68 public boolean remotelySettled();
69
70 /**
71 * TODO When does an application call this method? Do we really need this?
72 */
73 public void free();
74
75 /**
76 * @see Connection#getWorkHead()
77 */
78 public Delivery getWorkNext();
79
80 public Delivery next();
81
82 public boolean isWritable();
83
84 /**
85 * Returns whether this delivery has data ready to be received.
86 *
87 * @see Receiver#recv(byte[], int, int)
88 */
89 public boolean isReadable();
90
91 public void setContext(Object o);
92
93 public Object getContext();
94
95 /**
96 * Returns whether this delivery's state or settled flag has ever remotely changed.
97 *
98 * TODO what is the main intended use case for calling this method?
99 */
100 public boolean isUpdated();
101
102 public void clear();
103
104 /**
105 * Check for whether the delivery is still partial.
106 *
107 * For a receiving Delivery, this means the delivery does not hold
108 * a complete message payload as all the content hasn't been
109 * received yet. Note that an {@link #isAborted() aborted} delivery
110 * will also be considered partial and the full payload won't
111 * be received.
112 *
113 * For a sending Delivery, this means the sender link has not been
114 * {@link Sender#advance() advanced} to complete the delivery yet.
115 *
116 * @return true if the delivery is partial
117 * @see #isAborted()
118 */
119 public boolean isPartial();
120
121 /**
122 * Check for whether the delivery was aborted.
123 *
124 * @return true if the delivery was aborted.
125 */
126 boolean isAborted();
127
128 public int pending();
129
130 public boolean isBuffered();
131
132 /**
133 * Configures a default DeliveryState to be used if a
134 * received delivery is settled/freed without any disposition
135 * state having been previously applied.
136 *
137 * @param state the default delivery state
138 */
139 public void setDefaultDeliveryState(DeliveryState state);
140
141 public DeliveryState getDefaultDeliveryState();
142
143 /**
144 * Sets the message-format for this Delivery, representing the 32bit value using an int.
145 *
146 * The default value is 0 as per the message format defined in the core AMQP 1.0 specification.<p>
147 *
148 * See the following for more details:<br>
149 * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer">
150 * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer</a><br>
151 * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format">
152 * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format</a><br>
153 * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format">
154 * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format</a><br>
155 * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT">
156 * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT</a><br>
157 *
158 * @param messageFormat the message format
159 */
160 public void setMessageFormat(int messageFormat);
161
162 /**
163 * Gets the message-format for this Delivery, representing the 32bit value using an int.
164 *
165 * @return the message-format
166 * @see #setMessageFormat(int)
167 */
168 public int getMessageFormat();
169
170 /**
171 * Returns the number of bytes currently available for this delivery, which may not be complete yet, that are still
172 * to either be received by the application or sent by the transport.
173 *
174 * Note that this value will change as bytes are received/sent, and is in general not equal to the total length of
175 * a delivery, except the point where {@link #isPartial()} returns false and no content has yet been received by the
176 * application or sent by the transport.
177 *
178 * @return the number of bytes currently available for the delivery
179 *
180 * @see Receiver#recv(byte[], int, int)
181 * @see Receiver#recv(org.apache.qpid.proton.codec.WritableBuffer)
182 * @see Sender#send(byte[], int, int)
183 * @see Sender#send(org.apache.qpid.proton.codec.ReadableBuffer)
184 */
185 int available();
186 }