Package org.apache.camel

Examples of org.apache.camel.ExchangeTimedOutException


                    done = latch.await(timeout, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    // ignore
                }
                if (!done) {
                    exchange.setException(new ExchangeTimedOutException(exchange, timeout));
                    // remove timed out Exchange from queue
                    endpoint.getQueue().remove(copy);
                    // count down to indicate timeout
                    latch.countDown();
                }
View Full Code Here


    public void testVmTimeoutWithAnotherVm() throws Exception {
        try {
            template2.requestBody("vm:start1?timeout=4000", "Hello");
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(2000, cause.getTimeout());
        }
    }
View Full Code Here

    public void testVmTimeoutWithProcessor() throws Exception {
        try {
            template2.requestBody("vm:start2?timeout=4000", "Hello");
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(2000, cause.getTimeout());
        }
    }
View Full Code Here

                from("vm:start2?timeout=4000")
                    .to("log:AFTER_START2")
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            // this exception will trigger to stop asap
                            throw new ExchangeTimedOutException(exchange, 2000);
                        }
                    })
                    .to("log:AFTER_PROCESSOR");
            }
        };
View Full Code Here

        try {
            template2.requestBody("vm:a?timeout=1000", "Hello World");
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            // the chained vm caused the timeout
            ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(200, cause.getTimeout());
        }
       
        long delta = watch.stop();

        assertTrue("Should be faster than 1 sec, was: " + delta, delta < 1100);
View Full Code Here

            queue.add(copy);
            // lets see if we can get the task done before the timeout
            boolean done = latch.await(timeout, TimeUnit.MILLISECONDS);
            if (!done) {
                exchange.setException(new ExchangeTimedOutException(exchange, timeout));
            }
        } else {
            // no wait, eg its a InOnly then just add to queue and return
            queue.add(copy);
        }
View Full Code Here

                } catch (Exception e) {
                    exchange.setException(e);
                }
            } else if (exchangeState == HttpExchange.STATUS_EXPIRED) {
                // we did timeout
                exchange.setException(new ExchangeTimedOutException(exchange, client.getTimeout()));
            } else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
                // some kind of other error
                exchange.setException(new CamelExchangeException("JettyClient failed with state " + exchangeState, exchange));
            }
        } finally {
View Full Code Here

    public void testTimeout() throws Exception {
        try {
            template.request(url, null);
            fail("Should have thrown a timeout exception");
        } catch (Exception e) {
            ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(2000, cause.getTimeout());
        }
    }
View Full Code Here

        StopWatch watch = new StopWatch();
        try {
            template.requestBody("seda:a?timeout=5000", "Hello World");
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(2000, cause.getTimeout());
        }
        long delta = watch.stop();

        assertTrue("Should be faster than 4000 millis, was: " + delta, delta < 4000);
    }
View Full Code Here

        if (exchangeState == HttpExchange.STATUS_COMPLETED) {
            // process the response as the state is ok
            getBinding().populateResponse(exchange, httpExchange);
        } else if (exchangeState == HttpExchange.STATUS_EXPIRED) {
            // we did timeout
            throw new ExchangeTimedOutException(exchange, client.getTimeout());
        } else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
            // some kind of other error
            throw new CamelExchangeException("JettyClient failed with state " + exchangeState, exchange);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.ExchangeTimedOutException

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.