Skip to content

Commit 448ae70

Browse files
committed
Correctly closing connections for groups of threads
Fixes #17
1 parent 8f0d854 commit 448ae70

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/com/rabbitmq/perf/MulticastSet.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,26 @@ public void run(boolean announceStartup)
122122
producerThread.start();
123123
}
124124

125+
int count = 1; // counting the threads
125126
for (int i = 0; i < producerThreads.length; i++) {
126127
producerThreads[i].join();
127-
producerConnections[i].close();
128+
if(count % params.getProducerChannelCount() == 0) {
129+
// this is the end of a group of threads on the same connection,
130+
// closing the connection
131+
producerConnections[count / params.getProducerChannelCount() - 1].close();
132+
}
133+
count++;
128134
}
129135

136+
count = 1; // counting the threads
130137
for (int i = 0; i < consumerThreads.length; i++) {
131138
consumerThreads[i].join();
132-
consumerConnections[i].close();
139+
if(count % params.getConsumerChannelCount() == 0) {
140+
// this is the end of a group of threads on the same connection,
141+
// closing the connection
142+
consumerConnections[count / params.getConsumerChannelCount() - 1].close();
143+
}
144+
count++;
133145
}
134146
}
135147

0 commit comments

Comments
 (0)