Package org.apache.camel

Examples of org.apache.camel.ExchangeTimedOutException


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


                    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

                exchange.getIn().setBody(is);
            }
        });
        Exception e = reply.getException();
        assertNotNull("Should have thrown an exception", e);
        ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e);
        assertEquals(2000, cause.getTimeout());
        assertTrue("The input stream should be closed", is.isClosed());
    }
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 {
                // some kind of other error
                if (exchange.getException() != null) {
                    exchange.setException(new CamelExchangeException("JettyClient failed with state " + exchangeState, exchange, exchange.getException()));
                }
View Full Code Here

        if (sync) {
            // wait for response, consider timeout
            LOG.debug("Waiting for response using timeout {} millis.", timeout);
            boolean done = latch.await(timeout, TimeUnit.MILLISECONDS);
            if (!done) {
                throw new ExchangeTimedOutException(exchange, timeout);
            }

            // did we get a response
            ResponseHandler handler = (ResponseHandler) session.getHandler();
            if (handler.getCause() != null) {
                throw new CamelExchangeException("Error occurred in ResponseHandler", exchange, handler.getCause());
            } else if (!handler.isMessageReceived()) {
                // no message received
                throw new ExchangeTimedOutException(exchange, timeout);
            } else {
                // set the result on either IN or OUT on the original exchange depending on its pattern
                if (ExchangeHelper.isOutCapable(exchange)) {
                    Mina2PayloadHelper.setOut(exchange, handler.getMessage());
                } else {
View Full Code Here

                                new Object[]{holder.getRequestTimeout(), holder.getCorrelationId(), ExchangeHelper.logIds(exchange)});
                    }

                    // 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());
                    // the JmsBinding is designed to be "pull-based": it will populate the Camel message on demand
                    // therefore, we link Exchange and OUT message before continuing, so that the JmsBinding has full access
                    // to everything it may need, and can populate headers, properties, etc. accordingly (solves CAMEL-6218).
View Full Code Here

        try {
            template.requestBodyAndHeader("direct:start", "World", JmsConstants.JMS_REQUEST_TIMEOUT, 1500L, String.class);
            fail("Should have thrown exception");
        } catch (CamelExecutionException e) {
            ExchangeTimedOutException timeout = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
            assertEquals(1500, timeout.getTimeout());
        }

        assertMockEndpointsSatisfied();
    }
View Full Code Here

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

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

                    // exchange. If false, it will simply disregard the exchange.
                    // But since the Property map is a Concurrent one, maybe we don't need the AtomicBoolean. Check with Simon.
                    // Also check the TimeoutHandler of the new Disruptor 3.0.0, consider making the switch to the latest version.
                    exchange.setProperty(DisruptorEndpoint.DISRUPTOR_IGNORE_EXCHANGE, true);

                    exchange.setException(new ExchangeTimedOutException(exchange, timeout));

                    // count down to indicate timeout
                    latch.countDown();
                }
            } else {
View Full Code Here

        try {
            template2.requestBody("disruptor-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

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.