-
Notifications
You must be signed in to change notification settings - Fork 26
/
ProtonLink.java
237 lines (210 loc) · 6.03 KB
/
ProtonLink.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.vertx.proton;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import org.apache.qpid.proton.amqp.transport.ErrorCondition;
import org.apache.qpid.proton.amqp.transport.Source;
import org.apache.qpid.proton.amqp.transport.Target;
import org.apache.qpid.proton.engine.Record;
/**
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public interface ProtonLink<T extends ProtonLink<T>> {
/**
* Opens the AMQP link, i.e. allows the Attach frame to be emitted. Typically used after any additional configuration
* is performed on the object.
*
* For locally initiated links, the {@link #openHandler(Handler)} may be used to handle the peer sending their Attach
* frame.
*
* @return the link
*/
T open();
/**
* Closes the AMQP link, i.e. allows the Detach frame to be emitted with closed=true set.
*
* If the closure is being locally initiated, the {@link #closeHandler(Handler)} should be used to handle the peer
* sending their Detach frame with closed=true (and {@link #detachHandler(Handler)} can be used to handle the peer
* sending their Detach frame with closed=false).
*
* @return the link
*/
T close();
/**
* Detaches the AMQP link, i.e. allows the Detach frame to be emitted with closed=false.
*
* If the detach is being locally initiated, the {@link #detachHandler(Handler)} should be used to handle the peer
* sending their Detach frame with closed=false (and {@link #closeHandler(Handler)} can be used to handle the peer
* sending their Detach frame with closed=true).
*
* @return the link
*/
T detach();
/**
* Sets a handler for when an AMQP Attach frame is received from the remote peer.
*
* Typically used by clients, servers rely on {@link ProtonConnection#senderOpenHandler(Handler)} and
* {@link ProtonConnection#receiverOpenHandler(Handler)}.
*
* @param remoteOpenHandler
* the handler
* @return the link
*/
T openHandler(Handler<AsyncResult<T>> remoteOpenHandler);
/**
* Sets a handler for when an AMQP Detach frame with closed=true is received from the remote peer.
*
* @param remoteCloseHandler
* the handler
* @return the link
*/
T closeHandler(Handler<AsyncResult<T>> remoteCloseHandler);
/**
* Sets a handler for when an AMQP Detach frame with closed=false is received from the remote peer.
*
* @param remoteDetachHandler
* the handler
* @return the link
*/
T detachHandler(Handler<AsyncResult<Void>> remoteDetachHandler);
/**
* Gets the local QOS config.
*
* @return the QOS config
*/
ProtonQoS getQoS();
/**
* Sets the local QOS config.
*
* @param qos
* the QOS to configure
* @return the link
*/
T setQoS(ProtonQoS qos);
/**
* Gets the remote QOS config.
*
* @return the QOS config
*/
ProtonQoS getRemoteQoS();
/**
* Check whether the link is locally open.
*
* @return whether the link is locally open.
*/
boolean isOpen();
/**
* Retrieves the attachments record, upon which application items can be set/retrieved.
*
* @return the attachments
*/
Record attachments();
/**
* Gets the current local target config.
*
* @return the target
*/
Target getTarget();
/**
* Sets the current local target config. Only useful to call before the link has locally opened.
*
* @param target
* the target
* @return the link
*/
T setTarget(Target target);
/**
* Gets the current remote target config. Only useful to call after the link has remotely opened.
*
* @return the target
*/
Target getRemoteTarget();
/**
* Gets the current local source config.
*
* @return the source
*/
Source getSource();
/**
* Sets the current local source config. Only useful to call before the link has locally opened.
*
* @param source
* the source
* @return the link
*/
T setSource(Source source);
/**
* Gets the current remote source config. Only useful to call after the link has remotely opened.
*
* @return the target
*/
Source getRemoteSource();
/**
* Gets the session this link is on.
* @return the session
*/
ProtonSession getSession();
/**
* Sets the local ErrorCondition object.
*
* @param condition
* the condition to set
* @return the link
*/
T setCondition(ErrorCondition condition);
/**
* Gets the local ErrorCondition object.
*
* @return the condition
*/
ErrorCondition getCondition();
/**
* Gets the remote ErrorCondition object.
*
* @return the condition
*/
ErrorCondition getRemoteCondition();
/**
* Retrieves the current amount of credit.
*
* For a receiver link, the value returned will still include the credits that will be used by any queued
* incoming messages, use {@link #getQueued()} to assess the number of credits that will be used by queued messages.
*
* @return the number of credits
*/
int getCredit();
/**
* Retrieves the current value of link 'drain' flag.
*
* @return when the link drain flag is set.
*/
boolean getDrain();
/**
* Retrieves the current number of queued messages.
*
* For a receiver link, this is the number of messages that have already arrived locally but not yet been processed.
*
* @return the number of queues messages
*/
int getQueued();
/**
* Retrieves the link name
*
* @return the link name
*/
String getName();
}