use of org.apache.camel.util.StopWatch in project camel by apache.
the class NotAllowRedeliveryWhileStoppingDeadLetterChannelTest method testRedelivery.
public void testRedelivery() throws Exception {
StopWatch watch = new StopWatch();
MockEndpoint before = getMockEndpoint("mock:foo");
before.expectedMessageCount(1);
template.sendBody("seda:start", "Hello World");
assertMockEndpointsSatisfied();
Thread.sleep(500);
context.stopRoute("foo");
// we should reject the task and stop quickly
assertTrue("Should stop quickly: " + watch.taken(), watch.taken() < 5000);
// should go to DLC
Exchange dead = getMockEndpoint("mock:dead").getExchanges().get(0);
assertNotNull(dead);
Throwable cause = dead.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
assertNotNull(cause);
assertIsInstanceOf(RejectedExecutionException.class, cause);
assertEquals("Redelivery not allowed while stopping", cause.getMessage());
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class NotAllowRedeliveryWhileStoppingTest method testRedelivery.
public void testRedelivery() throws Exception {
StopWatch watch = new StopWatch();
MockEndpoint before = getMockEndpoint("mock:foo");
before.expectedMessageCount(1);
template.sendBody("seda:start", "Hello World");
assertMockEndpointsSatisfied();
Thread.sleep(500);
context.stop();
// we should reject the task and stop quickly
assertTrue("Should stop quickly: " + watch.taken(), watch.taken() < 5000);
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class AggregateSimpleExpressionIssueTest method xxxtestAggregateSimpleExpression.
// Enable me for manual unit testing
public void xxxtestAggregateSimpleExpression() throws Exception {
// 10 files + 10 files * 100 batches
int files = 10;
int rows = 100000;
int batches = rows / 1000;
int total = files + (files * rows) + (files * batches);
LOG.info("There are " + total + " exchanges");
NotifyBuilder notify = new NotifyBuilder(context).whenDone(total).create();
LOG.info("Writing 10 files with 100000 rows in each file");
// write 10 files of 100k rows
for (int i = 0; i < files; i++) {
Writer out = IOHelper.buffered(new FileWriter(new File("target/files", "data" + i)));
for (int j = 0; j < rows; j++) {
out.write(DATA);
}
out.close();
}
// start the route
StopWatch watch = new StopWatch();
context.startRoute("foo");
LOG.info("Waiting to process all the files");
boolean matches = notify.matches(3, TimeUnit.MINUTES);
LOG.info("Should process all files " + matches);
LOG.info("Time taken " + watch.taken() + " ms");
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class ChunkComponentTest method testChunkPerformance.
/**
* Performance test
*/
@Test
public void testChunkPerformance() throws Exception {
int messageCount = 10000;
endSimpleMock.expectedMessageCount(messageCount);
StopWatch stopwatch = new StopWatch(true);
for (int i = 0; i < messageCount; i++) {
startSimpleProducerTemplate.sendBodyAndHeader("The Body", "name", "Andrew");
}
assertMockEndpointsSatisfied();
LoggerFactory.getLogger(getClass()).info("Chunk performance: " + stopwatch.stop() + "ms for " + messageCount + " messages");
}
use of org.apache.camel.util.StopWatch in project camel by apache.
the class DefaultCamelContext method doResume.
@Override
protected void doResume() throws Exception {
try {
EventHelper.notifyCamelContextResuming(this);
log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is resuming");
StopWatch watch = new StopWatch();
// start the suspended routes (do not check for route clashes, and indicate)
doStartOrResumeRoutes(suspendedRouteServices, false, true, true, false);
// mark the route services as resumed (will be marked as started) as well
for (RouteService service : suspendedRouteServices.values()) {
if (routeSupportsSuspension(service.getId())) {
service.resume();
} else {
service.start();
}
}
watch.stop();
if (log.isInfoEnabled()) {
log.info("Resumed " + suspendedRouteServices.size() + " routes");
log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") resumed in " + TimeUtils.printDuration(watch.taken()));
}
// and clear the list as they have been resumed
suspendedRouteServices.clear();
EventHelper.notifyCamelContextResumed(this);
} catch (Exception e) {
EventHelper.notifyCamelContextResumeFailed(this, e);
throw e;
}
}
Aggregations