Skip to content

Commit 5b0c630

Browse files
author
Simon MacMullen
committed
Merge bug20005 into default.
2 parents b887541 + 6474fc4 commit 5b0c630

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/com/rabbitmq/client/QueueingConsumer.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,37 @@
4040
import com.rabbitmq.utility.Utility;
4141

4242
/**
43-
* Convenience class: an implementation of {@link Consumer} with straightforward blocking semantics
43+
* Convenience class: an implementation of {@link Consumer} with
44+
* straightforward blocking semantics.
45+
*
46+
* The general pattern for using QueueingConsumer is as follows:
47+
*
48+
* <pre>
49+
* // Create connection and channel.
50+
* {@link ConnectionFactory} factory = new ConnectionFactory();
51+
* Connection conn = factory.newConnection();
52+
* {@link Channel} ch1 = conn.createChannel();
53+
*
54+
* // Declare a queue and bind it to an exchange.
55+
* String queueName = ch1.queueDeclare().{@link AMQP.Queue.DeclareOk#getQueue getQueue}();
56+
* ch1.{@link Channel#queueBind queueBind}(queueName, exchangeName, queueName);
57+
*
58+
* // Create the QueueingConsumer and have it consume from the queue
59+
* QueueingConsumer consumer = new {@link QueueingConsumer#QueueingConsumer QueueingConsumer}(ch1);
60+
* ch1.{@link Channel#basicConsume basicConsume}(queueName, false, consumer);
61+
*
62+
* // Process deliveries
63+
* while (/* some condition * /) {
64+
* {@link QueueingConsumer.Delivery} delivery = consumer.{@link QueueingConsumer#nextDelivery nextDelivery}();
65+
* // process delivery
66+
* ch1.{@link Channel#basicAck basicAck}(delivery.{@link QueueingConsumer.Delivery#getEnvelope getEnvelope}().{@link Envelope#getDeliveryTag getDeliveryTag}(), false);
67+
* }
68+
* </pre>
69+
*
70+
* <p>For a more detailed explanation, see <a href="http://www.rabbitmq.com/api-guide.html#consuming">the java api guide</a>.</p>
71+
*
72+
* <p>For a more complete example, see LogTail in the test/src/com/rabbitmq/examples
73+
* directory of the source distribution.</p>
4474
*/
4575
public class QueueingConsumer extends DefaultConsumer {
4676
private final BlockingQueue<Delivery> _queue;

0 commit comments

Comments
 (0)