Permalink
Browse files

Merge pull request #1540 from clebertsuconic/master-fix

HORNETQ-910 - Honor given max rate in createConsumer from max rate <= 0 ...
  • Loading branch information...
2 parents 0c749dd + e8785c4 commit 02fbf5db47ab0427a683969c3355d2e90560510b @clebertsuconic clebertsuconic committed Feb 14, 2014
@@ -1995,7 +1995,7 @@ private ClientConsumer internalCreateConsumer(final SimpleString queueName,
browseOnly,
clientWindowSize,
ackBatchSize,
- consumerMaxRate > 0 ? new TokenBucketLimiterImpl(maxRate,
+ maxRate > 0 ? new TokenBucketLimiterImpl(maxRate,
false)
: null,
executor,
@@ -117,6 +117,45 @@ public void testConsumeRate() throws Exception
session.close();
}
+
+ @Test
+ public void testConsumeRate2() throws Exception
+ {
+ HornetQServer server = createServer(false);
+
+ server.start();
+
+ ClientSessionFactory sf = createSessionFactory(locator);
+
+ ClientSession session = sf.createSession(false, true, true);
+
+ session.createQueue(ADDRESS, ADDRESS, true);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ for (int i = 0; i < 12; i++)
+ {
+ producer.send(session.createMessage(false));
+ }
+
+ session.start();
+
+ ClientConsumer consumer = session.createConsumer(ADDRESS, null, 1024 * 1024, 10, false);
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < 12; i++)
+ {
+ consumer.receive(1000);
+ }
+
+ long end = System.currentTimeMillis();
+
+ Assert.assertTrue("TotalTime = " + (end - start), end - start >= 1000);
+
+ session.close();
+ }
+
@Test
public void testConsumeRateListener() throws Exception
{

0 comments on commit 02fbf5d

Please sign in to comment.