1111// The Original Code is RabbitMQ.
1212//
1313// 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.
1515//
1616
1717package com .rabbitmq .client ;
4545 * </ul>
4646 * <p>
4747 *
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.
5159 *
5260 */
5361
@@ -361,9 +369,9 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
361369 * Bind an exchange to an exchange, with no extra arguments.
362370 * @see com.rabbitmq.client.AMQP.Exchange.Bind
363371 * @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
367375 * @return a binding-confirm method if the binding was successfully created
368376 * @throws java.io.IOException if an error is encountered
369377 */
@@ -373,10 +381,10 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
373381 * Bind an exchange to an exchange.
374382 * @see com.rabbitmq.client.AMQP.Exchange.Bind
375383 * @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)
380388 * @return a binding-confirm method if the binding was successfully created
381389 * @throws java.io.IOException if an error is encountered
382390 */
@@ -386,9 +394,9 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
386394 * Unbind an exchange from an exchange, with no extra arguments.
387395 * @see com.rabbitmq.client.AMQP.Exchange.Bind
388396 * @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
392400 * @return a binding-confirm method if the binding was successfully created
393401 * @throws java.io.IOException if an error is encountered
394402 */
@@ -398,10 +406,10 @@ Exchange.DeclareOk exchangeDeclare(String exchange,
398406 * Unbind an exchange from an exchange.
399407 * @see com.rabbitmq.client.AMQP.Exchange.Bind
400408 * @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)
405413 * @return a binding-confirm method if the binding was successfully created
406414 * @throws java.io.IOException if an error is encountered
407415 */
@@ -737,34 +745,40 @@ void basicNack(long deliveryTag, boolean multiple, boolean requeue)
737745 /**
738746 * Wait until all messages published since the last call have been
739747 * 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 .
741749 * @return whether all the messages were ack'd (and none were nack'd)
750+ * @throws java.lang.IllegalStateException
742751 */
743752 boolean waitForConfirms () throws InterruptedException ;
744753
745754 /**
746755 * Wait until all messages published since the last call have been
747756 * either ack'd or nack'd by the broker; or until timeout elapses.
748757 * 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 .
751760 * @return whether all the messages were ack'd (and none were nack'd)
761+ * @throws java.lang.IllegalStateException
752762 */
753763 boolean waitForConfirms (long timeout ) throws InterruptedException , TimeoutException ;
754764
755765 /** Wait until all messages published since the last call have
756766 * been either ack'd or nack'd by the broker. If any of the
757767 * messages were nack'd, waitForConfirmsOrDie will throw an
758768 * 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 ;
761773
762774 /** Wait until all messages published since the last call have
763775 * been either ack'd or nack'd by the broker; or until timeout elapses.
764776 * If the timeout expires a TimeoutException is thrown. If any of the
765777 * messages were nack'd, waitForConfirmsOrDie will throw an
766778 * IOException. When called on a non-Confirm channel, it will
767- * return immediately. */
779+ * throw an IllegalStateException.
780+ * @throws java.lang.IllegalStateException
781+ */
768782 void waitForConfirmsOrDie (long timeout ) throws IOException , InterruptedException , TimeoutException ;
769783
770784 /**
0 commit comments