Package org.apache.camel.builder

Examples of org.apache.camel.builder.NotifyBuilder$ExchangeNotifier


        super.setUp();
    }

    public void testFileConsumeDoneFileIssue() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();

        template.sendBodyAndHeader("file:target/done", "A", Exchange.FILE_NAME, "foo-a.txt");
        template.sendBodyAndHeader("file:target/done", "B", Exchange.FILE_NAME, "foo-b.txt");
        template.sendBodyAndHeader("file:target/done", "C", Exchange.FILE_NAME, "foo-c.txt");
        template.sendBodyAndHeader("file:target/done", "D", Exchange.FILE_NAME, "foo-d.txt");
        template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo-e.txt");
        template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo.done");

        assertTrue("Done file should exists", new File("target/done/foo.done").exists());

        getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A", "B", "C", "D", "E");

        context.startRoute("foo");

        assertMockEndpointsSatisfied();
        assertTrue(notify.matchesMockWaitTime());

        Thread.sleep(250);

        // the done file should be deleted
        assertFalse("Done file should be deleted", new File("target/done/foo.done").exists());
View Full Code Here


        // the done file should be deleted
        assertFalse("Done file should be deleted", new File("target/done/foo.done").exists());
    }
   
    public void testFileConsumseDynamicDoneFileName() 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());
View Full Code Here

        return "ftp://admin@localhost:" + getPort() + "?password=admin";
    }

    @Test
    public void testFromFileToFtpDelete() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);

        template.sendBodyAndHeader("file:target/delete", "Hello World", Exchange.FILE_NAME, "hello.txt");

        assertMockEndpointsSatisfied();
        assertTrue(notify.matchesMockWaitTime());

        // file should be deleted
        File file = new File("target/delete/hello.txt");
        assertFalse("File should be deleted", file.exists());
View Full Code Here

        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");
    }
View Full Code Here

        super.setUp();
    }

    @Test
    public void testXPathSTaXPerformanceRoute() 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");
View Full Code Here

    }

    private void doSendMessages(int files, int poolSize) throws Exception {
        Mailbox.clearAll();

        NotifyBuilder builder = new NotifyBuilder(context).whenDone(files).create();

        getMockEndpoint("mock:result").expectedMessageCount(files);
        getMockEndpoint("mock:result").expectsNoDuplicates(body());

        final CountDownLatch latch = new CountDownLatch(files);
        ExecutorService executor = Executors.newFixedThreadPool(poolSize);
        for (int i = 0; i < files; i++) {
            final int index = i;
            executor.submit(new Callable<Object>() {
                public Object call() throws Exception {
                    template.sendBodyAndHeader("direct:start", "Message " + index, "To", "someone@localhost");
                    latch.countDown();
                    return null;
                }
            });
        }

        // wait first for all the exchanges above to be thoroughly sent asynchronously
        assertTrue(latch.await(5, TimeUnit.SECONDS));

        assertMockEndpointsSatisfied();
        assertTrue(builder.matchesMockWaitTime());

        Mailbox box = Mailbox.get("someone@localhost");
        assertEquals(files, box.size());

        // as we use concurrent producers the mails can arrive out of order
View Full Code Here

                        setHeader(CacheConstants.CACHE_KEY, constant(10L)).
                        to("cache://TestCache1");
            }
        });
        context.start();
        NotifyBuilder notify = new NotifyBuilder(context).whenExactlyDone(1).create();

        LOG.debug("------------Beginning CacheProducer Add Test---------------");
        sendOriginalFile();

        notify.matches(10, TimeUnit.SECONDS);
        assertNotNull(fetchElement("10"));
    }
View Full Code Here

*/
public class FileToFtpTempFileNameTest extends FtpServerTestSupport {

    @Test
    public void testFileToFtp() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        template.sendBodyAndHeader("file:target/in", "Hello World", Exchange.FILE_NAME, "sub/hello.txt");

        assertTrue(notify.matchesMockWaitTime());

        File file = new File(FTP_ROOT_DIR + "/out/sub/hello.txt");
        assertTrue("File should exists " + file, file.exists());
    }
View Full Code Here

        super.setUp();
    }

    @Test
    public void testFtpRoute() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
        resultEndpoint.expectedMessageCount(2);

        prepareFtpServer();

        context.startRoute("foo");

        assertMockEndpointsSatisfied();
        assertTrue(notify.matchesMockWaitTime());

        Exchange ex = resultEndpoint.getExchanges().get(0);
        byte[] bytes = ex.getIn().getBody(byte[].class);
        assertTrue("Logo size wrong", bytes.length > 10000);
View Full Code Here

    }

    @Test
    @Ignore("Manual test")
    public void testXPathPerformanceRoute() 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");
View Full Code Here

TOP

Related Classes of org.apache.camel.builder.NotifyBuilder$ExchangeNotifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.