Package org.apache.camel.builder

Examples of org.apache.camel.builder.NotifyBuilder


    public void testFileToHdfs() throws Exception {
        if (!canTest()) {
            return;
        }

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

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

        notify.matchesMockWaitTime();

        File delete = new File("target/inbox/hello.txt");
        assertTrue("File should be deleted " + delete, !delete.exists());

        File create = new File(TEMP_DIR + "/output.txt");
View Full Code Here


    public void testTwoFilesToHdfs() throws Exception {
        if (!canTest()) {
            return;
        }

        NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();

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

        notify.matchesMockWaitTime();

        File delete = new File("target/inbox/hello.txt");
        assertTrue("File should be deleted " + delete, !delete.exists());
        delete = new File("target/inbox/bye.txt");
        assertTrue("File should be deleted " + delete, !delete.exists());
View Full Code Here

    /**
     * Convenient api to create a NotifyBuilder to be notified of a specific event
     */
    protected NotifyBuilder event() {
        return new NotifyBuilder(context);
    }
View Full Code Here

    public void testDummy() {
        // this is a manual test
    }

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

        boolean matches = notify.matches(5, TimeUnit.MINUTES);
        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

        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 = new BufferedWriter(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

    private int size = 100;

    @Test
    public void testJmsRequestReplyExclusiveFixedReplyTo() throws Exception {
        NotifyBuilder builder = new NotifyBuilder(context).from("direct:start").whenDone(size).create();

        StopWatch watch = new StopWatch();
        ExecutorService executor = Executors.newFixedThreadPool(10);
        for (int i = 0; i < size; i++) {
            final Integer num = i;
            executor.submit(new Runnable() {
                @Override
                public void run() {
                    String reply = template.requestBody("direct:start", "" + num, String.class);
                    log.info("Sent {} expecting reply 'Hello {}' got --> {}", new Object[]{num, num, reply});
                    assertNotNull(reply);
                    assertEquals("Hello " + num, reply);
                }
            });
        }

        log.info("Waiting to process {} messages...", size);
        assertTrue(builder.matches(60, TimeUnit.SECONDS));

        long delta = watch.stop();
        log.info("Took {} millis", delta);

        // just sleep a bit before shutting down
View Full Code Here

    /**
     * Convenient api to create a NotifyBuilder to be notified of a specific event
     */
    protected NotifyBuilder event() {
        return new NotifyBuilder(context);
    }
View Full Code Here

    private static volatile String sync;
    private static volatile String lastOne;

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

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

        template.sendBody("direct:start", "Hello World");

        assertMockEndpointsSatisfied();
        notify.matchesMockWaitTime();

        assertEquals("onCompleteA", sync);
        assertEquals("onCompleteA", lastOne);
    }
View Full Code Here

public class BeanBeforeAggregateIssueTest extends ContextTestSupport {

    private MyAggRepo myRepo = new MyAggRepo();

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

    @Test
    public void testJmsToJdbcJmsCommit() throws Exception {
        checkInitialState();

        // use a notify to know when the message is done
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

        // use mock during testing as well
        getMockEndpoint("mock:a").expectedMessageCount(1);
        getMockEndpoint("mock:b").expectedMessageCount(1);

        template.sendBodyAndHeader("activemq:queue:inbox", "A", "uid", 123);

        // assert mock and wait for the message to be done
        assertMockEndpointsSatisfied();
        assertTrue("Should complete 1 message", notify.matchesMockWaitTime());

        // check that there is a message in the database and JMS queue
        assertEquals(1, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
        Object out = consumer.receiveBody("activemq:queue:outbox", 3000);
        assertEquals("DONE-A", out);
View Full Code Here

TOP

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

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.