2222import java .net .URISyntaxException ;
2323import java .security .KeyManagementException ;
2424import java .security .NoSuchAlgorithmException ;
25+ import java .util .ArrayList ;
26+ import java .util .Collection ;
2527import java .util .HashSet ;
2628import java .util .List ;
2729import java .util .Random ;
@@ -74,6 +76,7 @@ public void run() throws IOException, InterruptedException, TimeoutException, No
7476 public void run (boolean announceStartup )
7577 throws IOException , InterruptedException , TimeoutException , NoSuchAlgorithmException , KeyManagementException , URISyntaxException {
7678 Set <String > queueNames = new HashSet <>();
79+ Collection <Consumer > consumers = new ArrayList <>();
7780 Thread [] consumerThreads = new Thread [params .getConsumerThreadCount ()];
7881 Connection [] consumerConnections = new Connection [params .getConsumerCount ()];
7982 for (int i = 0 ; i < consumerConnections .length ; i ++) {
@@ -88,6 +91,7 @@ public void run(boolean announceStartup)
8891 System .out .println ("id: " + testID + ", starting consumer #" + i + ", channel #" + j );
8992 }
9093 Consumer consumer = params .createConsumer (conn , stats , routingKey );
94+ consumers .add (consumer );
9195 queueNames .addAll (consumer .getQueueNames ());
9296 Thread t = new Thread (consumer );
9397 consumerThreads [(i * params .getConsumerChannelCount ()) + j ] = t ;
@@ -111,6 +115,12 @@ public void run(boolean announceStartup)
111115 producersRoutingKey = this .routingKey ;
112116 }
113117
118+ // consumers need the publishing routing key to match it against
119+ // against the received message and update the stats
120+ for (Consumer consumer : consumers ) {
121+ consumer .setRoutingKey (producersRoutingKey );
122+ }
123+
114124 Thread [] producerThreads = new Thread [params .getProducerThreadCount ()];
115125 Connection [] producerConnections = new Connection [params .getProducerCount ()];
116126 for (int i = 0 ; i < producerConnections .length ; i ++) {
0 commit comments