Skip to content

Commit 3ac74f7

Browse files
author
Matthew Sackman
committed
Merging bug22828 onto default
2 parents aebdc50 + defc417 commit 3ac74f7

35 files changed

+214
-168
lines changed

build.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,19 @@
388388
</junit>
389389
</target>
390390

391+
<target name="test-single" depends="test-build">
392+
<junit printSummary="withOutAndErr"
393+
haltOnFailure="${haltOnFailureJunit}"
394+
failureproperty="test.failure"
395+
fork="yes">
396+
<classpath refid="test.classpath"/>
397+
398+
<formatter type="plain"/>
399+
<formatter type="xml"/>
400+
<test todir="${build.out}" name="${test}"/>
401+
</junit>
402+
</target>
403+
391404
<target name="jar" depends="build">
392405
<mkdir dir="${lib.out}"/>
393406
<antcall target="doJarWithTags">

src/com/rabbitmq/client/Channel.java

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.rabbitmq.client.AMQP.Exchange;
3838
import com.rabbitmq.client.AMQP.Queue;
3939
import com.rabbitmq.client.AMQP.Tx;
40+
import com.rabbitmq.client.AMQP.Basic;
4041
import com.rabbitmq.client.AMQP.Channel.FlowOk;
4142

4243
/**
@@ -91,10 +92,10 @@ public interface Channel extends ShutdownNotifier {
9192
* @throws java.io.IOException if an error is encountered
9293
*/
9394
void close(int closeCode, String closeMessage) throws IOException;
94-
95+
9596
/**
9697
* Set flow on the channel
97-
*
98+
*
9899
* @param active if true, the server is asked to start sending. If false, the server is asked to stop sending.
99100
* @throws IOException
100101
*/
@@ -183,38 +184,17 @@ public interface Channel extends ShutdownNotifier {
183184
void basicPublish(String exchange, String routingKey, boolean mandatory, boolean immediate, BasicProperties props, byte[] body)
184185
throws IOException;
185186

186-
/**
187-
* Delete an exchange, without regard for whether it is in use or not
188-
* @see com.rabbitmq.client.AMQP.Exchange.Delete
189-
* @see com.rabbitmq.client.AMQP.Exchange.DeleteOk
190-
* @param exchange the name of the exchange
191-
* @return a deletion-confirm method to indicate the exchange was successfully deleted
192-
* @throws java.io.IOException if an error is encountered
193-
*/
194-
Exchange.DeleteOk exchangeDelete(String exchange) throws IOException;
195-
196187
/**
197188
* Actively declare a non-autodelete, non-durable exchange with no extra arguments
198189
* @see com.rabbitmq.client.AMQP.Exchange.Declare
199190
* @see com.rabbitmq.client.AMQP.Exchange.DeclareOk
200191
* @param exchange the name of the exchange
201192
* @param type the exchange type
202-
* @return a deletion-confirm method to indicate the exchange was successfully deleted
193+
* @return a declaration-confirm method to indicate the exchange was successfully declared
203194
* @throws java.io.IOException if an error is encountered
204195
*/
205196
Exchange.DeclareOk exchangeDeclare(String exchange, String type) throws IOException;
206197

207-
/**
208-
* Delete an exchange
209-
* @see com.rabbitmq.client.AMQP.Exchange.Delete
210-
* @see com.rabbitmq.client.AMQP.Exchange.DeleteOk
211-
* @param exchange the name of the exchange
212-
* @param ifUnused true to indicate that the exchange is only to be deleted if it is unused
213-
* @return a deletion-confirm method to indicate the exchange was successfully deleted
214-
* @throws java.io.IOException if an error is encountered
215-
*/
216-
Exchange.DeleteOk exchangeDelete(String exchange, boolean ifUnused) throws IOException;
217-
218198
/**
219199
* Actively declare a non-autodelete exchange with no extra arguments
220200
* @see com.rabbitmq.client.AMQP.Exchange.Declare
@@ -228,70 +208,88 @@ void basicPublish(String exchange, String routingKey, boolean mandatory, boolean
228208
Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean durable) throws IOException;
229209

230210
/**
231-
* Declare an exchange, via an interface that allows the complete set of arguments
232-
* The name of the new queue is held in the "queue" field of the {@link com.rabbitmq.client.AMQP.Queue.DeclareOk} result.
211+
* Declare an exchange, via an interface that allows the complete set of arguments.
233212
* @see com.rabbitmq.client.AMQP.Exchange.Declare
234213
* @see com.rabbitmq.client.AMQP.Exchange.DeclareOk
235214
* @param exchange the name of the exchange
236215
* @param type the exchange type
237-
* @param passive true if we are passively declaring a exchange (asserting the exchange already exists)
238216
* @param durable true if we are declaring a durable exchange (the exchange will survive a server restart)
239217
* @param autoDelete true if the server should delete the exchange when it is no longer in use
240218
* @param arguments other properties (construction arguments) for the exchange
241219
* @return a declaration-confirm method to indicate the exchange was successfully declared
242220
* @throws java.io.IOException if an error is encountered
243221
*/
244-
Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean passive, boolean durable, boolean autoDelete,
222+
Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean durable, boolean autoDelete,
245223
Map<String, Object> arguments) throws IOException;
246224

247225
/**
248-
* Actively declare a server-named exclusive, autodelete, non-durable queue.
249-
* The name of the new queue is held in the "queue" field of the {@link com.rabbitmq.client.AMQP.Queue.DeclareOk} result.
250-
* @see com.rabbitmq.client.AMQP.Queue.Declare
251-
* @see com.rabbitmq.client.AMQP.Queue.DeclareOk
252-
* @return a declaration-confirm method to indicate the exchange was successfully declared
226+
* Declare an exchange passively; that is, check if the named exchange exists.
227+
* @param name check the existence of an exchange named this
228+
* @param type the exchange type
229+
* @throws IOException the server will raise a 404 channel exception if the named exchange does not exist.
230+
*/
231+
Exchange.DeclareOk exchangeDeclarePassive(String name, String type) throws IOException;
232+
233+
/**
234+
* Delete an exchange
235+
* @see com.rabbitmq.client.AMQP.Exchange.Delete
236+
* @see com.rabbitmq.client.AMQP.Exchange.DeleteOk
237+
* @param exchange the name of the exchange
238+
* @param ifUnused true to indicate that the exchange is only to be deleted if it is unused
239+
* @return a deletion-confirm method to indicate the exchange was successfully deleted
253240
* @throws java.io.IOException if an error is encountered
254241
*/
255-
Queue.DeclareOk queueDeclare() throws IOException;
242+
Exchange.DeleteOk exchangeDelete(String exchange, boolean ifUnused) throws IOException;
256243

257244
/**
258-
* Actively declare a non-exclusive, non-autodelete, non-durable queue
259-
* @see com.rabbitmq.client.AMQP.Queue.Declare
260-
* @see com.rabbitmq.client.AMQP.Queue.DeclareOk
261-
* @param queue the name of the queue
262-
* @return a declaration-confirm method to indicate the queue was successfully declared
245+
* Delete an exchange, without regard for whether it is in use or not
246+
* @see com.rabbitmq.client.AMQP.Exchange.Delete
247+
* @see com.rabbitmq.client.AMQP.Exchange.DeleteOk
248+
* @param exchange the name of the exchange
249+
* @return a deletion-confirm method to indicate the exchange was successfully deleted
263250
* @throws java.io.IOException if an error is encountered
264251
*/
265-
Queue.DeclareOk queueDeclare(String queue) throws IOException;
252+
Exchange.DeleteOk exchangeDelete(String exchange) throws IOException;
266253

267254
/**
268-
* Actively declare a non-exclusive, non-autodelete queue
255+
* Actively declare a server-named exclusive, autodelete, non-durable queue.
269256
* The name of the new queue is held in the "queue" field of the {@link com.rabbitmq.client.AMQP.Queue.DeclareOk} result.
270257
* @see com.rabbitmq.client.AMQP.Queue.Declare
271258
* @see com.rabbitmq.client.AMQP.Queue.DeclareOk
272-
* @param queue the name of the queue
273-
* @param durable true if we are declaring a durable exchange (the exchange will survive a server restart)
274-
* @return a declaration-confirm method to indicate the exchange was successfully declared
259+
* @return a declaration-confirm method to indicate the queue was successfully declared
275260
* @throws java.io.IOException if an error is encountered
276261
*/
277-
Queue.DeclareOk queueDeclare(String queue, boolean durable) throws IOException;
262+
Queue.DeclareOk queueDeclare() throws IOException;
278263

279264
/**
280265
* Declare a queue
281266
* @see com.rabbitmq.client.AMQP.Queue.Declare
282267
* @see com.rabbitmq.client.AMQP.Queue.DeclareOk
283268
* @param queue the name of the queue
284-
* @param passive true if we are passively declaring a queue (asserting the queue already exists)
285269
* @param durable true if we are declaring a durable queue (the queue will survive a server restart)
286-
* @param exclusive true if we are declaring an exclusive queue
270+
* @param exclusive true if we are declaring an exclusive queue (restricted to this connection)
287271
* @param autoDelete true if we are declaring an autodelete queue (server will delete it when no longer in use)
288272
* @param arguments other properties (construction arguments) for the queue
289273
* @return a declaration-confirm method to indicate the queue was successfully declared
290274
* @throws java.io.IOException if an error is encountered
291275
*/
292-
Queue.DeclareOk queueDeclare(String queue, boolean passive, boolean durable, boolean exclusive, boolean autoDelete,
276+
Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, boolean autoDelete,
293277
Map<String, Object> arguments) throws IOException;
294278

279+
/**
280+
* Declare a queue passively; i.e., check if it exists. In AMQP
281+
* 0-9-1, all arguments aside from nowait are ignored; and sending
282+
* nowait makes this method a no-op, so we default it to false.
283+
* @see com.rabbitmq.client.AMQP.Queue.Declare
284+
* @see com.rabbitmq.client.AMQP.Queue.DeclareOk
285+
* @param queue the name of the queue
286+
* @return a declaration-confirm method to indicate the queue exists
287+
* @throws java.io.IOException if an error is encountered,
288+
* including if the queue does not exist and if the queue is
289+
* exclusively owned by another connection.
290+
*/
291+
Queue.DeclareOk queueDeclarePassive(String queue) throws IOException;
292+
295293
/**
296294
* Delete a queue, without regard for whether it is in use or has messages on it
297295
* @see com.rabbitmq.client.AMQP.Queue.Delete

src/com/rabbitmq/client/RpcClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void close() throws IOException {
119119
* @return the name of the reply queue
120120
*/
121121
protected String setupReplyQueue() throws IOException {
122-
return _channel.queueDeclare("", false, false, true, true, null).getQueue();
122+
return _channel.queueDeclare("", false, true, true, null).getQueue();
123123
}
124124

125125
/**

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -285,21 +285,21 @@ public void close()
285285
{
286286
close(AMQP.REPLY_SUCCESS, "OK");
287287
}
288-
288+
289289
/** Public API - {@inheritDoc} */
290290
public void close(int closeCode, String closeMessage)
291291
throws IOException
292292
{
293293
close(closeCode, closeMessage, true, null, false);
294294
}
295-
295+
296296
/** Public API - {@inheritDoc} */
297297
public void abort()
298298
throws IOException
299299
{
300300
abort(AMQP.REPLY_SUCCESS, "OK");
301301
}
302-
302+
303303
/** Public API - {@inheritDoc} */
304304
public void abort(int closeCode, String closeMessage)
305305
throws IOException
@@ -331,7 +331,7 @@ public void close(int closeCode,
331331
if (cause != null) {
332332
signal.initCause(cause);
333333
}
334-
334+
335335
BlockingRpcContinuation<AMQCommand> k = new SimpleBlockingRpcContinuation();
336336
boolean notify = false;
337337
try {
@@ -341,7 +341,7 @@ public void close(int closeCode,
341341
processShutdownSignal(signal, !initiatedByApplication, true);
342342
quiescingRpc(reason, k);
343343
}
344-
344+
345345
// Now that we're in quiescing state, channel.close was sent and
346346
// we wait for the reply. We ignore the result. (It's always
347347
// close-ok.)
@@ -366,7 +366,7 @@ public void close(int closeCode,
366366
notifyListeners();
367367
}
368368
}
369-
}
369+
}
370370

371371
/** Public API - {@inheritDoc} */
372372
public void basicQos(int prefetchSize, int prefetchCount, boolean global)
@@ -407,13 +407,13 @@ public void basicPublish(String exchange, String routingKey,
407407

408408
/** Public API - {@inheritDoc} */
409409
public Exchange.DeclareOk exchangeDeclare(String exchange, String type,
410-
boolean passive, boolean durable,
411-
boolean autoDelete, Map<String, Object> arguments)
410+
boolean durable, boolean autoDelete,
411+
Map<String, Object> arguments)
412412
throws IOException
413413
{
414414
return (Exchange.DeclareOk)
415415
exnWrappingRpc(new Exchange.Declare(TICKET, exchange, type,
416-
passive, durable, autoDelete,
416+
false, durable, autoDelete,
417417
false, false, arguments)).getMethod();
418418
}
419419

@@ -422,14 +422,24 @@ public Exchange.DeclareOk exchangeDeclare(String exchange, String type,
422422
boolean durable)
423423
throws IOException
424424
{
425-
return exchangeDeclare(exchange, type, false, durable, false, null);
425+
return exchangeDeclare(exchange, type, durable, false, null);
426426
}
427427

428428
/** Public API - {@inheritDoc} */
429429
public Exchange.DeclareOk exchangeDeclare(String exchange, String type)
430430
throws IOException
431431
{
432-
return exchangeDeclare(exchange, type, false, false, false, null);
432+
return exchangeDeclare(exchange, type, false, false, null);
433+
}
434+
435+
/** Public API - {@inheritDoc} */
436+
public Exchange.DeclareOk exchangeDeclarePassive(String exchange, String type)
437+
throws IOException
438+
{
439+
return (Exchange.DeclareOk)
440+
exnWrappingRpc(new Exchange.Declare(TICKET, exchange, type,
441+
true, false, false,
442+
false, false, null)).getMethod();
433443
}
434444

435445
/** Public API - {@inheritDoc} */
@@ -448,35 +458,29 @@ public Exchange.DeleteOk exchangeDelete(String exchange)
448458
}
449459

450460
/** Public API - {@inheritDoc} */
451-
public Queue.DeclareOk queueDeclare(String queue, boolean passive,
452-
boolean durable, boolean exclusive,
461+
public Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive,
453462
boolean autoDelete, Map<String, Object> arguments)
454463
throws IOException
455464
{
456465
return (Queue.DeclareOk)
457-
exnWrappingRpc(new Queue.Declare(TICKET, queue, passive, durable,
466+
exnWrappingRpc(new Queue.Declare(TICKET, queue, false, durable,
458467
exclusive, autoDelete, false, arguments)).getMethod();
459468
}
460469

461470
/** Public API - {@inheritDoc} */
462-
public Queue.DeclareOk queueDeclare(String queue, boolean durable)
463-
throws IOException
464-
{
465-
return queueDeclare(queue, false, durable, false, false, null);
466-
}
467-
468-
/** Public API - {@inheritDoc} */
469-
public Queue.DeclareOk queueDeclare(String queue)
471+
public com.rabbitmq.client.AMQP.Queue.DeclareOk queueDeclare()
470472
throws IOException
471473
{
472-
return queueDeclare(queue, false, false, false, false, null);
474+
return queueDeclare("", false, true, true, null);
473475
}
474476

475477
/** Public API - {@inheritDoc} */
476-
public com.rabbitmq.client.AMQP.Queue.DeclareOk queueDeclare()
478+
public Queue.DeclareOk queueDeclarePassive(String queue)
477479
throws IOException
478480
{
479-
return queueDeclare("", false, false, true, true, null);
481+
return (Queue.DeclareOk)
482+
exnWrappingRpc(new Queue.Declare(TICKET, queue, true, false,
483+
true, true, false, null)).getMethod();
480484
}
481485

482486
/** Public API - {@inheritDoc} */
@@ -486,7 +490,7 @@ public Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean ifEmpt
486490
return (Queue.DeleteOk)
487491
exnWrappingRpc(new Queue.Delete(TICKET, queue, ifUnused, ifEmpty, false)).getMethod();
488492
}
489-
493+
490494
/** Public API - {@inheritDoc} */
491495
public Queue.DeleteOk queueDelete(String queue)
492496
throws IOException
@@ -674,7 +678,7 @@ public void basicRecoverAsync(boolean requeue)
674678
{
675679
transmit(new Basic.Recover(requeue));
676680
}
677-
681+
678682
/** Public API - {@inheritDoc} */
679683
public Tx.SelectOk txSelect()
680684
throws IOException
@@ -698,6 +702,6 @@ public Tx.RollbackOk txRollback()
698702

699703
/** Public API - {@inheritDoc} */
700704
public Channel.FlowOk flow(final boolean a) throws IOException {
701-
return (Channel.FlowOk) exnWrappingRpc(new Channel.Flow() {{active = a;}}).getMethod();
705+
return (Channel.FlowOk) exnWrappingRpc(new Channel.Flow() {{active = a;}}).getMethod();
702706
}
703707
}

test/src/com/rabbitmq/client/test/BrokerTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected void declareDurableDirectExchange(String x) throws IOException {
201201
}
202202

203203
protected void declareDurableQueue(String q) throws IOException {
204-
channel.queueDeclare(q, true);
204+
channel.queueDeclare(q, true, false, false, null);
205205
}
206206

207207
protected void declareDurableTopicExchange(String x) throws IOException {

test/src/com/rabbitmq/client/test/Bug20004Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testBug20004()
6161
public void run() {
6262
try {
6363
synchronized (channel) {
64-
channel.queueDeclare("Bug20004Test");
64+
channel.queueDeclare("Bug20004Test", false, false, false, null);
6565
testInstance.created = true;
6666
}
6767
} catch (Exception e) {

0 commit comments

Comments
 (0)