File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 4040import 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, "amq.direct", 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, true, consumer);
61+ *
62+ * // Process deliveries
63+ * while (true) {
64+ * {@link QueueingConsumer.Delivery} delivery = consumer.{@link QueueingConsumer#nextDelivery nextDelivery}();
65+ * // process delivery
66+ * }
67+ * </pre>
68+ *
69+ * For a more complete example, see LogTail in the test/src/com/rabbitmq/examples
70+ * directory of the source distribution.
4471 */
4572public class QueueingConsumer extends DefaultConsumer {
4673 private final BlockingQueue <Delivery > _queue ;
You can’t perform that action at this time.
0 commit comments