use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class ThreadsRejectedExecutionTest method testThreadsRejectedDiscard.
public void testThreadsRejectedDiscard() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:start").to("log:before").threads(1, 1).maxPoolSize(1).maxQueueSize(2).rejectedPolicy(ThreadPoolRejectedPolicy.Discard).delay(1000).to("log:after").to("mock:result");
}
});
context.start();
NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
getMockEndpoint("mock:result").expectedMinimumMessageCount(2);
for (int i = 0; i < 10; i++) {
template.sendBody("seda:start", "Message " + i);
}
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
int inflight = context.getInflightRepository().size();
assertEquals(0, inflight);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class XPathSplitChoicePerformanceTest method xxTestXPatPerformanceRoute.
public void xxTestXPatPerformanceRoute() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create();
boolean matches = notify.matches(60, TimeUnit.SECONDS);
log.info("Processed file with " + size + " elements in: " + TimeUtils.printDuration(watch.stop()));
log.info("Processed " + tiny.get() + " tiny messages");
log.info("Processed " + small.get() + " small messages");
log.info("Processed " + med.get() + " medium messages");
log.info("Processed " + large.get() + " large messages");
assertEquals((size / 10) * 4, tiny.get());
assertEquals((size / 10) * 2, small.get());
assertEquals((size / 10) * 3, med.get());
assertEquals((size / 10) * 1, large.get());
assertTrue("Should complete route", matches);
}
use of org.apache.camel.builder.NotifyBuilder 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.builder.NotifyBuilder in project camel by apache.
the class BeanBeforeAggregateIssueTest method testBeanBeforeAggregation.
public void testBeanBeforeAggregation() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
getMockEndpoint("mock:result").expectedBodiesReceived("A+B");
template.sendBody("seda:start", "A");
template.sendBody("seda:start", "B");
assertMockEndpointsSatisfied();
// wait for all exchanges to be done (2 input + 1 aggregated)
notify.matches(5, TimeUnit.SECONDS);
// should have confirmed
assertTrue("Should have confirmed", myRepo.isConfirm());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class FileConsumeDoneFileIssueTest method testFileConsumeDynamicDoneFileName.
public void testFileConsumeDynamicDoneFileName() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
template.sendBodyAndHeader("file:target/done2", "A", Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader("file:target/done2", "B", Exchange.FILE_NAME, "b.txt");
template.sendBodyAndHeader("file:target/done2", "C", Exchange.FILE_NAME, "c.txt");
template.sendBodyAndHeader("file:target/done2", "a", Exchange.FILE_NAME, "a.txt.done");
template.sendBodyAndHeader("file:target/done2", "b", Exchange.FILE_NAME, "b.txt.done");
template.sendBodyAndHeader("file:target/done2", "c", Exchange.FILE_NAME, "c.txt.done");
assertTrue("Done file should exists", new File("target/done2/a.txt.done").exists());
assertTrue("Done file should exists", new File("target/done2/b.txt.done").exists());
assertTrue("Done file should exists", new File("target/done2/c.txt.done").exists());
getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A", "B", "C");
context.startRoute("bar");
assertMockEndpointsSatisfied();
assertTrue(notify.matchesMockWaitTime());
Thread.sleep(250);
// the done file should be deleted
assertFalse("Done file should be deleted", new File("target/done2/a.txt.done").exists());
assertFalse("Done file should be deleted", new File("target/done2/b.txt.done").exists());
assertFalse("Done file should be deleted", new File("target/done2/c.txt.done").exists());
}
Aggregations