adaptor.start(); // start the adaptor
Destination destination = adaptor.getDestination(); // get the destination
// send a message
final Sender sender = factory.getSender(destination);
final int numAdaptorThreads = adaptor.executor.getNumThreads();
assertTrue(numAdaptorThreads > 1);
DefaultDempsyExecutor executor = ((DefaultDempsyExecutor)adaptor.executor);
// first dump the max number of messages
for (int i = 0; i < executor.getMaxNumberOfQueuedLimitedTasks(); i++)
sender.send("Hello".getBytes());
// wait until there's room in the queue due to messages being passed on to
// the receiver; one for each thread.
assertTrue(TestUtils.poll(baseTimeoutMillis, receiver, new TestUtils.Condition<StringListener>()
{ @Override public boolean conditionMet(StringListener o) { return o.numIn.get() == numAdaptorThreads; } }));
// send one more for each opened up place in the queue now
for (int i = 0; i < numAdaptorThreads; i++)
sender.send("Hello".getBytes());
// wait until all Listeners are in and all threads enqueued. This is the totally full state.
assertTrue(TestUtils.poll(baseTimeoutMillis, ((DefaultDempsyExecutor)adaptor.executor), new TestUtils.Condition<DefaultDempsyExecutor>()
{ @Override public boolean conditionMet(DefaultDempsyExecutor o) { return o.getNumberLimitedPending() == o.getMaxNumberOfQueuedLimitedTasks(); } }));
assertEquals(0,statsCollector.getDiscardedMessageCount());
// we are going to poll but we are going to keep adding to the queu of tasks. So we add 2, let one go,
// until we start seeing rejects.
assertTrue(TestUtils.poll(baseTimeoutMillis, statsCollector,
new TestUtils.Condition<BasicStatsCollector>() {
@Override public boolean conditionMet(BasicStatsCollector o) throws Throwable
{
sender.send("Hello".getBytes());
sender.send("Hello".getBytes());
synchronized(latch)
{
latch.notify(); // single exit.
}