managedQueue.setCapacity(DEFAULT_MESSAGE_SIZE * 3l);
final ManagedConnection managedConnection = getConnectionMBean();
// Check that producer flow is not block before test
final CompositeDataSupport rowBeforeSend = getTheOneChannelRow(managedConnection);
assertFlowBlocked(rowBeforeSend, false);
// Check that producer flow does not become block too soon
sendMessage(session, queue, 3);
final CompositeDataSupport rowBeforeFull = getTheOneChannelRow(managedConnection);
assertFlowBlocked(rowBeforeFull, false);
// Fourth message will over-fill the queue (but as we are not sending more messages, client thread wont't block)
sendMessage(session, queue, 1);
final CompositeDataSupport rowAfterFull = getTheOneChannelRow(managedConnection);
assertFlowBlocked(rowAfterFull, true);
// Consume two to bring the queue down to the resume capacity
MessageConsumer consumer = session.createConsumer(queue);
assertNotNull("Could not receive first message", consumer.receive(1000));
assertNotNull("Could not receive second message", consumer.receive(1000));
session.commit();
// Check that producer flow is no longer blocked
final CompositeDataSupport rowAfterReceive = getTheOneChannelRow(managedConnection);
assertFlowBlocked(rowAfterReceive, false);
}