Package org.apache.camel

Examples of org.apache.camel.PollingConsumer.start()


        // sleep just a little
        Thread.sleep(2000);

        PollingConsumer consumer = context.getEndpoint("activemq:queue:bar").createPollingConsumer();
        consumer.start();

        // use timeout in case running on slow box
        Exchange bar = consumer.receive(10000);
        assertNotNull("Should be a message on queue", bar);
View Full Code Here


        // sleep more so the message is expired
        Thread.sleep(5000);

        PollingConsumer consumer = context.getEndpoint("activemq:queue:bar").createPollingConsumer();
        consumer.start();

        Exchange bar = consumer.receiveNoWait();
        assertNull("Should NOT be a message on queue", bar);

        consumer.stop();
View Full Code Here

        // sleep just a little
        Thread.sleep(50);

        PollingConsumer consumer = context.getEndpoint("activemq:queue:bar").createPollingConsumer();
        consumer.start();

        Exchange bar = consumer.receive(5000);
        assertNotNull("Should be a message on queue", bar);

        consumer.stop();
View Full Code Here

        // sleep more so the message is expired
        Thread.sleep(5000);

        PollingConsumer consumer = context.getEndpoint("activemq:queue:bar").createPollingConsumer();
        consumer.start();

        Exchange bar = consumer.receiveNoWait();
        assertNull("Should NOT be a message on queue", bar);

        consumer.stop();
View Full Code Here

     * down the consumer and throws any exceptions thrown.
     */
    public static void pollEndpoint(Endpoint endpoint, Processor processor, long timeout) throws Exception {
        PollingConsumer consumer = endpoint.createPollingConsumer();
        try {
            consumer.start();

            while (true) {
                Exchange exchange = consumer.receive(timeout);
                if (exchange == null) {
                    break;
View Full Code Here

     * down the consumer and throws any exceptions thrown.
     */
    public static void pollEndpoint(Endpoint endpoint, Processor processor, long timeout) throws Exception {
        PollingConsumer consumer = endpoint.createPollingConsumer();
        try {
            consumer.start();

            while (true) {
                Exchange exchange = consumer.receive(timeout);
                if (exchange == null) {
                    break;
View Full Code Here

        String key = endpoint.getEndpointUri();
        PollingConsumer answer = consumers.get(key);
        if (answer == null) {
            try {
                answer = endpoint.createPollingConsumer();
                answer.start();
            } catch (Exception e) {
                throw new FailedToCreateConsumerException(endpoint, e);
            }

            boolean singleton = true;
View Full Code Here

        String key = endpoint.getEndpointUri();
        PollingConsumer answer = consumers.get(key);
        if (answer == null) {
            try {
                answer = endpoint.createPollingConsumer();
                answer.start();
            } catch (Exception e) {
                throw new FailedToCreateConsumerException(endpoint, e);
            }

            boolean singleton = true;
View Full Code Here

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

        Endpoint endpoint = context.getEndpoint("file://target/fpc?fileName=hello.txt");
        PollingConsumer consumer = endpoint.createPollingConsumer();
        consumer.start();
        Exchange exchange = consumer.receive(5000);
        assertNotNull(exchange);

        assertEquals("hello.txt", exchange.getIn().getHeader(Exchange.FILE_NAME, String.class));
        assertEquals("Hello World", exchange.getIn().getBody(String.class));
View Full Code Here

    public void testPollingConsumer() throws Exception {
        deleteDirectory("target/enrich");
        template.sendBodyAndHeader("file:target/enrich", "Hello World", Exchange.FILE_NAME, "hello.txt");

        PollingConsumer consumer = context.getEndpoint("file:target/enrich").createPollingConsumer();
        consumer.start();
        Exchange exchange = consumer.receive(5000);
        assertNotNull(exchange);
        assertEquals("Hello World", exchange.getIn().getBody(String.class));

        // sleep a bit to ensure polling consumer would be suspended after we have used it
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.