ARTEMIS-638 Only allocate credits once Link Attach

This commit is contained in:
Martyn Taylor 2016-07-18 13:54:41 +01:00 committed by Andy Taylor
parent df41a60e21
commit 5dfa1c59fb
2 changed files with 24 additions and 1 deletions

View File

@ -69,7 +69,6 @@ public class ProtonServerConnectionContext extends AbstractConnectionContext imp
}
else {
protonSession.addReceiver(receiver);
receiver.flow(100);
}
}
else {

View File

@ -156,6 +156,30 @@ public class ProtonTest extends ActiveMQTestBase {
}
}
@Test
public void testCreditsAreAllocatedOnlyOnceOnLinkCreate() throws Exception {
if (protocol != 0 && protocol != 3) return; // Only run this test for AMQP protocol
// Only allow 1 credit to be submitted at a time.
Field maxCreditAllocation = ProtonServerReceiverContext.class.getDeclaredField("maxCreditAllocation");
maxCreditAllocation.setAccessible(true);
int originalMaxCreditAllocation = maxCreditAllocation.getInt(null);
maxCreditAllocation.setInt(null, 1);
String destinationAddress = address + 1;
AmqpClient client = new AmqpClient(new URI("tcp://localhost:5672"), userName, password);
AmqpConnection amqpConnection = client.connect();
try {
AmqpSession session = amqpConnection.createSession();
AmqpSender sender = session.createSender(destinationAddress);
assertTrue(sender.getSender().getCredit() == 1);
}
finally {
amqpConnection.close();
maxCreditAllocation.setInt(null, originalMaxCreditAllocation);
}
}
@Test
public void testTemporaryQueue() throws Throwable {