2828import com .rabbitmq .client .AMQP .Confirm ;
2929
3030/**
31- * Public API: Interface to an AMQ channel. See the <a href="http://www.amqp.org/">spec</a> for details.
31+ * Interface to a channel. All non-deprecated methods of
32+ * this interface are part of the public API.
3233 *
33- * <p>
34- * To open a channel,
35- * <pre>
36- * {@link Connection} conn = ...;
37- * {@link Channel} channel = conn.{@link Connection#createChannel createChannel}();
38- * </pre>
39- * <p>
40- * Public API:
41- * <ul>
42- * <li> getChannelNumber
43- * <li> close
44- * </ul>
45- * <p>
34+ * <h2>Tutorials</h2>
35+ * <a href="http://www.rabbitmq.com/getstarted.html">RabbitMQ tutorials</a> demonstrate how
36+ * key methods of this interface are used.
37+ *
38+ * <h2>User Guide</h2>
39+ * See <a href="http://www.rabbitmq.com/api-guide.html">Java Client User Guide</a>.
4640 *
41+ * <h2>Concurrency Considerations</h2>
4742 * <p>
48- * {@link Channel} instances are safe for use by multiple
49- * threads. Requests into a {@link Channel} are serialized, with only one
50- * thread running commands at a time.
51- * As such, applications may prefer using a {@link Channel} per thread
52- * instead of sharing the same <code>Channel</code> across multiple threads.
43+ * {@link Channel} instances must not be shared between
44+ * threads. Applications
45+ * should prefer using a {@link Channel} per thread
46+ * instead of sharing the same {@link Channel} across
47+ * multiple threads. While some operations on channels are safe to invoke
48+ * concurrently, some are not and will result in incorrect frame interleaving
49+ * on the wire. Sharing channels between threads will also interfere with
50+ * <a href="http://www.rabbitmq.com/confirms.html">Publisher Confirms</a>.
5351 *
54- * An <b>important caveat</b> to this is that confirms are <b>not</b> handled
55- * properly when a {@link Channel} is shared between multiple threads. In that
56- * scenario, it is therefore important to ensure that the {@link Channel}
57- * instance is <b>not</b> accessed concurrently by multiple threads.
52+ * As such, applications need to use a {@link Channel} per thread.
53+ * </p>
5854 *
55+ * @see <a href="http://www.rabbitmq.com/getstarted.html">RabbitMQ tutorials</a>
56+ * @see <a href="http://www.rabbitmq.com/api-guide.html">RabbitMQ Java Client User Guide</a>
5957 */
60-
6158public interface Channel extends ShutdownNotifier {
6259 /**
6360 * Retrieve this channel's channel number.
@@ -245,8 +242,16 @@ public interface Channel extends ShutdownNotifier {
245242 void basicQos (int prefetchCount ) throws IOException ;
246243
247244 /**
248- * Publish a message
245+ * Publish a message.
246+ *
247+ * Publishing to a non-existent exchange will result in a channel-level
248+ * protocol exception, which closes the channel.
249+ *
250+ * Invocations of <code>Channel#basicPublish</code> will eventually block if a
251+ * <a href="http://www.rabbitmq.com/alarms.html">resource-driven alarm</a> is in effect.
252+ *
249253 * @see com.rabbitmq.client.AMQP.Basic.Publish
254+ * @see <a href="http://www.rabbitmq.com/alarms.html">Resource-driven alarms</a>.
250255 * @param exchange the exchange to publish the message to
251256 * @param routingKey the routing key
252257 * @param props other properties for the message - routing headers etc
@@ -256,8 +261,13 @@ public interface Channel extends ShutdownNotifier {
256261 void basicPublish (String exchange , String routingKey , BasicProperties props , byte [] body ) throws IOException ;
257262
258263 /**
259- * Publish a message
264+ * Publish a message.
265+ *
266+ * Invocations of <code>Channel#basicPublish</code> will eventually block if a
267+ * <a href="http://www.rabbitmq.com/alarms.html">resource-driven alarm</a> is in effect.
268+ *
260269 * @see com.rabbitmq.client.AMQP.Basic.Publish
270+ * @see <a href="http://www.rabbitmq.com/alarms.html">Resource-driven alarms</a>.
261271 * @param exchange the exchange to publish the message to
262272 * @param routingKey the routing key
263273 * @param mandatory true if the 'mandatory' flag is to be set
@@ -269,8 +279,16 @@ void basicPublish(String exchange, String routingKey, boolean mandatory, BasicPr
269279 throws IOException ;
270280
271281 /**
272- * Publish a message
282+ * Publish a message.
283+ *
284+ * Publishing to a non-existent exchange will result in a channel-level
285+ * protocol exception, which closes the channel.
286+ *
287+ * Invocations of <code>Channel#basicPublish</code> will eventually block if a
288+ * <a href="http://www.rabbitmq.com/alarms.html">resource-driven alarm</a> is in effect.
289+ *
273290 * @see com.rabbitmq.client.AMQP.Basic.Publish
291+ * @see <a href="http://www.rabbitmq.com/alarms.html">Resource-driven alarms</a>.
274292 * @param exchange the exchange to publish the message to
275293 * @param routingKey the routing key
276294 * @param mandatory true if the 'mandatory' flag is to be set
0 commit comments