context.getProperties().put(Exchange.MAXIMUM_CACHE_POOL_SIZE, "200");
return context;
}
public void testCacheConsumers() throws Exception {
ConsumerTemplate template = context.createConsumerTemplate();
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
// test that we cache at most 500 producers to avoid it eating to much memory
for (int i = 0; i < 203; i++) {
Endpoint e = context.getEndpoint("direct:queue:" + i);
template.receiveNoWait(e);
}
assertEquals("Size should be 200", 200, template.getCurrentCacheSize());
template.stop();
// should be 0
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
}