2525import java .io .ByteArrayInputStream ;
2626import java .io .DataInputStream ;
2727import java .io .IOException ;
28- import java .util .HashMap ;
29- import java .util .Map ;
3028
3129public class Consumer implements Runnable {
3230
3331 private QueueingConsumer q ;
3432 private Channel channel ;
3533 private String id ;
3634 private String queueName ;
37- private int prefetch ;
3835 private int txSize ;
3936 private boolean autoAck ;
4037 private int multiAckEvery ;
@@ -43,12 +40,11 @@ public class Consumer implements Runnable {
4340 private long timeLimit ;
4441
4542 public Consumer (Channel channel , String id ,
46- String queueName , int prefetch , int txSize , boolean autoAck ,
43+ String queueName , int txSize , boolean autoAck ,
4744 int multiAckEvery , Stats stats , int msgLimit , int timeLimit ) {
4845
4946 this .channel = channel ;
5047 this .id = id ;
51- this .prefetch = prefetch ;
5248 this .queueName = queueName ;
5349 this .txSize = txSize ;
5450 this .autoAck = autoAck ;
@@ -66,7 +62,7 @@ public void run() {
6662
6763 try {
6864 q = new QueueingConsumer (channel );
69- channel .basicConsume (queueName , autoAck , args ( prefetch ), q );
65+ channel .basicConsume (queueName , autoAck , q );
7066
7167 while ((timeLimit == 0 || now < startTime + timeLimit ) &&
7268 (msgLimit == 0 || totalMsgCount < msgLimit )) {
@@ -81,7 +77,7 @@ public void run() {
8177 } catch (ConsumerCancelledException e ) {
8278 System .out .println ("Consumer cancelled by broker. Re-consuming." );
8379 q = new QueueingConsumer (channel );
84- channel .basicConsume (queueName , autoAck , args ( prefetch ), q );
80+ channel .basicConsume (queueName , autoAck , q );
8581 continue ;
8682 }
8783 totalMsgCount ++;
@@ -118,12 +114,4 @@ public void run() {
118114 throw new RuntimeException (e );
119115 }
120116 }
121-
122- private Map <String , Object > args (int prefetch ) {
123- Map <String , Object > a = new HashMap <String , Object >();
124- if (prefetch != 0 ) {
125- a .put ("x-prefetch" , prefetch );
126- }
127- return a ;
128- }
129117}
0 commit comments