11
11
// The Original Code is RabbitMQ.
12
12
//
13
13
// The Initial Developer of the Original Code is VMware, Inc.
14
- // Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
14
+ // Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
15
15
//
16
16
17
17
package com .rabbitmq .client ;
45
45
* </ul>
46
46
* <p>
47
47
*
48
- * While a Channel can be used by multiple threads, it's important to ensure
49
- * that only one thread executes a command at once. Concurrent execution of
50
- * commands will likely cause an UnexpectedFrameError to be thrown.
48
+ * <p>
49
+ * {@link Channel} instances are safe for use by multiple
50
+ * threads. Requests into a {@link Channel} are serialized, with only one
51
+ * thread running commands at a time.
52
+ * As such, applications may prefer using a {@link Channel} per thread
53
+ * instead of sharing the same <code>Channel</code> across multiple threads.
54
+ *
55
+ * An <b>important caveat</b> to this is that confirms are <b>not</b> handled
56
+ * properly when a {@link Channel} is shared between multiple threads. In that
57
+ * scenario, it is therefore important to ensure that the {@link Channel}
58
+ * instance is <b>not</b> accessed concurrently by multiple threads.
51
59
*
52
60
*/
53
61
@@ -361,9 +369,9 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
361
369
* Bind an exchange to an exchange, with no extra arguments.
362
370
* @see com.rabbitmq.client.AMQP.Exchange.Bind
363
371
* @see com.rabbitmq.client.AMQP.Exchange.BindOk
364
- * @param destination: the name of the exchange to which messages flow across the binding
365
- * @param source: the name of the exchange from which messages flow across the binding
366
- * @param routingKey: the routine key to use for the binding
372
+ * @param destination the name of the exchange to which messages flow across the binding
373
+ * @param source the name of the exchange from which messages flow across the binding
374
+ * @param routingKey the routine key to use for the binding
367
375
* @return a binding-confirm method if the binding was successfully created
368
376
* @throws java.io.IOException if an error is encountered
369
377
*/
@@ -373,10 +381,10 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
373
381
* Bind an exchange to an exchange.
374
382
* @see com.rabbitmq.client.AMQP.Exchange.Bind
375
383
* @see com.rabbitmq.client.AMQP.Exchange.BindOk
376
- * @param destination: the name of the exchange to which messages flow across the binding
377
- * @param source: the name of the exchange from which messages flow across the binding
378
- * @param routingKey: the routine key to use for the binding
379
- * @param arguments: other properties (binding parameters)
384
+ * @param destination the name of the exchange to which messages flow across the binding
385
+ * @param source the name of the exchange from which messages flow across the binding
386
+ * @param routingKey the routine key to use for the binding
387
+ * @param arguments other properties (binding parameters)
380
388
* @return a binding-confirm method if the binding was successfully created
381
389
* @throws java.io.IOException if an error is encountered
382
390
*/
@@ -386,9 +394,9 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
386
394
* Unbind an exchange from an exchange, with no extra arguments.
387
395
* @see com.rabbitmq.client.AMQP.Exchange.Bind
388
396
* @see com.rabbitmq.client.AMQP.Exchange.BindOk
389
- * @param destination: the name of the exchange to which messages flow across the binding
390
- * @param source: the name of the exchange from which messages flow across the binding
391
- * @param routingKey: the routine key to use for the binding
397
+ * @param destination the name of the exchange to which messages flow across the binding
398
+ * @param source the name of the exchange from which messages flow across the binding
399
+ * @param routingKey the routine key to use for the binding
392
400
* @return a binding-confirm method if the binding was successfully created
393
401
* @throws java.io.IOException if an error is encountered
394
402
*/
@@ -398,10 +406,10 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
398
406
* Unbind an exchange from an exchange.
399
407
* @see com.rabbitmq.client.AMQP.Exchange.Bind
400
408
* @see com.rabbitmq.client.AMQP.Exchange.BindOk
401
- * @param destination: the name of the exchange to which messages flow across the binding
402
- * @param source: the name of the exchange from which messages flow across the binding
403
- * @param routingKey: the routine key to use for the binding
404
- * @param arguments: other properties (binding parameters)
409
+ * @param destination the name of the exchange to which messages flow across the binding
410
+ * @param source the name of the exchange from which messages flow across the binding
411
+ * @param routingKey the routine key to use for the binding
412
+ * @param arguments other properties (binding parameters)
405
413
* @return a binding-confirm method if the binding was successfully created
406
414
* @throws java.io.IOException if an error is encountered
407
415
*/
@@ -737,34 +745,40 @@ void basicNack(long deliveryTag, boolean multiple, boolean requeue)
737
745
/**
738
746
* Wait until all messages published since the last call have been
739
747
* either ack'd or nack'd by the broker. Note, when called on a
740
- * non-Confirm channel, waitForConfirms returns true immediately .
748
+ * non-Confirm channel, waitForConfirms throws an IllegalStateException .
741
749
* @return whether all the messages were ack'd (and none were nack'd)
750
+ * @throws java.lang.IllegalStateException
742
751
*/
743
752
boolean waitForConfirms () throws InterruptedException ;
744
753
745
754
/**
746
755
* Wait until all messages published since the last call have been
747
756
* either ack'd or nack'd by the broker; or until timeout elapses.
748
757
* If the timeout expires a TimeoutException is thrown. When
749
- * called on a non-Confirm channel, waitForConfirms returns true
750
- * immediately .
758
+ * called on a non-Confirm channel, waitForConfirms throws an
759
+ * IllegalStateException .
751
760
* @return whether all the messages were ack'd (and none were nack'd)
761
+ * @throws java.lang.IllegalStateException
752
762
*/
753
763
boolean waitForConfirms (long timeout ) throws InterruptedException , TimeoutException ;
754
764
755
765
/** Wait until all messages published since the last call have
756
766
* been either ack'd or nack'd by the broker. If any of the
757
767
* messages were nack'd, waitForConfirmsOrDie will throw an
758
768
* IOException. When called on a non-Confirm channel, it will
759
- * return immediately. */
760
- void waitForConfirmsOrDie () throws IOException , InterruptedException ;
769
+ * throw an IllegalStateException.
770
+ * @throws java.lang.IllegalStateException
771
+ */
772
+ void waitForConfirmsOrDie () throws IOException , InterruptedException ;
761
773
762
774
/** Wait until all messages published since the last call have
763
775
* been either ack'd or nack'd by the broker; or until timeout elapses.
764
776
* If the timeout expires a TimeoutException is thrown. If any of the
765
777
* messages were nack'd, waitForConfirmsOrDie will throw an
766
778
* IOException. When called on a non-Confirm channel, it will
767
- * return immediately. */
779
+ * throw an IllegalStateException.
780
+ * @throws java.lang.IllegalStateException
781
+ */
768
782
void waitForConfirmsOrDie (long timeout ) throws IOException , InterruptedException , TimeoutException ;
769
783
770
784
/**
0 commit comments