@@ -90,7 +90,7 @@ public static void main(String[] args) {
9090
9191 //setup
9292 String id = UUID .randomUUID ().toString ();
93- Stats stats = new Stats (1000L * samplingInterval );
93+ Stats stats = new Stats (1000L * samplingInterval );
9494 ConnectionFactory factory = new ConnectionFactory ();
9595 factory .setHost (hostName );
9696 factory .setPort (portNumber );
@@ -128,20 +128,10 @@ public static void main(String[] args) {
128128 if (producerTxSize > 0 ) channel .txSelect ();
129129 channel .exchangeDeclare (exchangeName , exchangeType );
130130 final Producer p = new Producer (channel , exchangeName , id ,
131- flags , producerTxSize ,
132- 1000L * samplingInterval ,
133- rateLimit , minMsgSize , timeLimit );
134- channel .setReturnListener (new ReturnListener () {
135- public void handleBasicReturn (int replyCode ,
136- String replyText ,
137- String exchange ,
138- String routingKey ,
139- AMQP .BasicProperties properties ,
140- byte [] body )
141- throws IOException {
142- p .logBasicReturn ();
143- }
144- });
131+ flags , producerTxSize ,
132+ 1000L * samplingInterval ,
133+ rateLimit , minMsgSize , timeLimit );
134+ channel .setReturnListener (p );
145135 Thread t = new Thread (p );
146136 producerThreads [i ] = t ;
147137 t .start ();
@@ -209,7 +199,7 @@ private static List lstArg(CommandLine cmd, char opt) {
209199 return Arrays .asList (vals );
210200 }
211201
212- public static class Producer implements Runnable {
202+ public static class Producer implements Runnable , ReturnListener {
213203
214204 private Channel channel ;
215205 private String exchangeName ;
@@ -247,6 +237,15 @@ public Producer(Channel channel, String exchangeName, String id,
247237 this .message = new byte [minMsgSize ];
248238 }
249239
240+ public void handleBasicReturn (int replyCode ,
241+ String replyText ,
242+ String exchange ,
243+ String routingKey ,
244+ AMQP .BasicProperties properties ,
245+ byte [] body ) throws IOException {
246+ logBasicReturn ();
247+ }
248+
250249 public synchronized void logBasicReturn () {
251250 basicReturnCount ++;
252251 }
0 commit comments