Skip to content

Commit 62c97d5

Browse files
author
Matthew Sackman
committed
merge bug20943 in again
2 parents 159278e + 688b50b commit 62c97d5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/src/com/rabbitmq/client/test/functional/QosTests.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,31 +208,26 @@ public void testFairness()
208208

209209
}
210210

211-
public void testRoundRobin()
211+
public void testSingleChannelAndQueueFairness()
212212
throws IOException
213213
{
214214
//check that when we have multiple consumers on the same
215215
//channel & queue, and a prefetch limit set, that all
216-
//consumers get a fair share of the messages
216+
//consumers get a fair share of the messages.
217217

218218
channel.basicQos(1);
219219
String q = channel.queueDeclare().getQueue();
220220
channel.queueBind(q, "amq.fanout", "");
221221

222222
final Map<String, Integer> counts =
223223
Collections.synchronizedMap(new HashMap<String, Integer>());
224-
final String [] nextTag = new String[] { null };
225224

226225
QueueingConsumer c = new QueueingConsumer(channel) {
227226
@Override public void handleDelivery(String consumerTag,
228227
Envelope envelope,
229228
AMQP.BasicProperties properties,
230229
byte[] body)
231230
throws IOException {
232-
String otherConsumerTag = "c1".equals(consumerTag) ? "c2" : "c1";
233-
if (null != nextTag[0])
234-
assertEquals(consumerTag, nextTag[0]);
235-
nextTag[0] = otherConsumerTag;
236231
counts.put(consumerTag, counts.get(consumerTag) + 1);
237232
super.handleDelivery(consumerTag, envelope,
238233
properties, body);
@@ -242,7 +237,7 @@ public void testRoundRobin()
242237
channel.basicConsume(q, false, "c1", c);
243238
channel.basicConsume(q, false, "c2", c);
244239

245-
int count = 4;
240+
int count = 10;
246241
counts.put("c1", 0);
247242
counts.put("c2", 0);
248243
fill(count);
@@ -254,8 +249,12 @@ public void testRoundRobin()
254249
} catch (InterruptedException ie) {
255250
fail("interrupted");
256251
}
257-
assertEquals(count / 2, counts.get("c1").intValue());
258-
assertEquals(count / 2, counts.get("c2").intValue());
252+
253+
//we only check that the server isn't grossly unfair; perfect
254+
//fairness is too much to ask for (even though RabbitMQ atm
255+
//does actually provide it in this case)
256+
assertTrue(counts.get("c1").intValue() > 0);
257+
assertTrue(counts.get("c2").intValue() > 0);
259258
}
260259

261260
public void testConsumerLifecycle()

0 commit comments

Comments
 (0)