Package org.apache.camel.builder

Examples of org.apache.camel.builder.NotifyBuilder


        doSendMessages(250000, 100);
    }

    private void doSendMessages(int files, int poolSize) throws Exception {
        StopWatch watch = new StopWatch();
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(files).create();

        ExecutorService executor = Executors.newFixedThreadPool(poolSize);
        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer, Future<String>>();
        for (int i = 0; i < files; i++) {
            final int index = i;
            Future<String> out = executor.submit(new Callable<String>() {
                public String call() throws Exception {
                    String reply = template.requestBody("netty:tcp://localhost:{{port}}", index, String.class);
                    log.debug("Sent {} received {}", index, reply);
                    assertEquals("Bye " + index, reply);
                    return reply;
                }
            });
            responses.put(index, out);
        }

        notify.matches(2, TimeUnit.MINUTES);
        log.info("Took " + watch.taken() + " millis to process " + files + " messages using " + poolSize + " client threads.");
        assertEquals(files, responses.size());

        // get all responses
        Set<Object> unique = new HashSet<Object>();
View Full Code Here



            }
        });

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

        template.sendBody("activemq:queue:foo", "blah");

        notify.matchesMockWaitTime();

        assertTrue("Expected only 1 calls to process() (1 failure) but encountered "
                   + getConditionalExceptionProcessor().getCount() + "."
                   , getConditionalExceptionProcessor().getCount() == 1);
    }
View Full Code Here

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

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

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

                        .to("mock:result");
            }
        });
        context.start();

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

        getMockEndpoint("mock:result").expectedMessageCount(10);
        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);
    }
View Full Code Here

                        .to("mock:result");
            }
        });
        context.start();

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

        // there should be error handling for aborted tasks (eg no redeliveries and no error handling)
        getMockEndpoint("mock:error").expectedMessageCount(0);

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

    // disabled due manual test
    public void xxxtestSplitParallelBigFile() throws Exception {
        StopWatch watch = new StopWatch();

        NotifyBuilder builder = new NotifyBuilder(context).whenDone(lines + 1).create();
        boolean done = builder.matches(120, TimeUnit.SECONDS);

        log.info("Took " + TimeUtils.printDuration(watch.stop()));

        if (!done) {
            throw new CamelException("Could not split file in 2 minutes");
View Full Code Here

        return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/tx/JavaDSLTransactionTest.xml");
    }

    protected void assertResult() throws InterruptedException {
        // should be 1 completed and 1 failed
        NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();

        template.sendBody("activemq:queue:foo", "blah");

        notify.matchesMockWaitTime();

        assertTrue("Expected only 2 calls to process() (1 failure, 1 success) but encountered "
                   + getConditionalExceptionProcessor().getCount() + "."
                   , getConditionalExceptionProcessor().getCount() == 2);
    }
View Full Code Here

    private int port;

    @Test
    public void testJmsInOnlyHttpPostIssue() throws Exception {
        NotifyBuilder notify = new NotifyBuilder(context).whenCompleted(1).from("jms*").create();

        template.sendBody("jms:queue:in", "Hello World");

        assertTrue("Should complete the JMS route", notify.matchesMockWaitTime());
    }
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.