Package org.apache.camel

Examples of org.apache.camel.ExchangeTimedOutException


        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


        NettyHelper.writeBody(channel, null, body, exchange);

        if (configuration.isSync()) {
            boolean success = countdownLatch.await(configuration.getTimeout(), TimeUnit.MILLISECONDS);
            if (!success) {
                throw new ExchangeTimedOutException(exchange, configuration.getTimeout());
            }

            ClientChannelHandler handler = (ClientChannelHandler) clientPipeline.get("handler");
            if (handler.getCause() != null) {
                throw new CamelExchangeException("Error occurred in ClientChannelHandler", exchange, handler.getCause());
View Full Code Here

    public void testVmTimeoutWithAnotherVm() throws Exception {
        try {
            template.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

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

    public void testVmTimeoutWithProcessor() throws Exception {
        try {
            template.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");

                from("vm:end")
View Full Code Here

        StopWatch watch = new StopWatch();
        try {
            template.requestBody("vm: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

                        + " Setting ExchangeTimedOutException on ExchangeId: {} and continue routing.",
                        new Object[]{holder.getRequestTimeout(), holder.getCorrelationId(), exchange.getExchangeId()});

                // no response, so lets set a timed out exception
                String msg = "reply message with correlationID: " + holder.getCorrelationId() + " not received";
                exchange.setException(new ExchangeTimedOutException(exchange, holder.getRequestTimeout(), msg));
            } else {
                JmsMessage response = new JmsMessage(message, endpoint.getBinding());
                Object body = response.getBody();

                if (endpoint.isTransferException() && body instanceof Exception) {
View Full Code Here

                    message.setJMSCorrelationID(correlationId);
                    exchange.getOut().setHeader("JMSCorrelationID", correlationId);
                }
            } else {
                // no response, so lets set a timed out exception
                exchange.setException(new ExchangeTimedOutException(exchange, requestTimeout));
            }
        } catch (Exception e) {
            exchange.setException(e);
        }
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

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.