Package org.apache.camel

Examples of org.apache.camel.RollbackExchangeException


            template.sendBody("direct:start", "A,B,Kaboom,C");
            fail("Should thrown an exception");
        } catch (CamelExecutionException e) {
            CamelExchangeException ee = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
            assertTrue(ee.getMessage().startsWith("Sequential processing failed for number 2. Exchange[Message: Kaboom]"));
            RollbackExchangeException re = assertIsInstanceOf(RollbackExchangeException.class, ee.getCause());
            assertEquals("Intended rollback. Exchange[Message: Kaboom]", re.getMessage());
        }

        assertMockEndpointsSatisfied();
    }
View Full Code Here


            template.sendBody("direct:start", "A,Forced,B,Kaboom,C");
            fail("Should thrown an exception");
        } catch (CamelExecutionException e) {
            CamelExchangeException ee = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
            assertTrue(ee.getMessage().startsWith("Sequential processing failed for number 3. Exchange[Message: Kaboom]"));
            RollbackExchangeException re = assertIsInstanceOf(RollbackExchangeException.class, ee.getCause());
            assertEquals("Intended rollback. Exchange[Message: Kaboom]", re.getMessage());
        }

        assertMockEndpointsSatisfied();
    }
View Full Code Here

    public void process(Exchange exchange) throws Exception {
        // mark the exchange for rollback
        exchange.setProperty(Exchange.ROLLBACK_ONLY, Boolean.TRUE);
        if (message != null) {
            exchange.setException(new RollbackExchangeException(message, exchange));
        } else {
            exchange.setException(new RollbackExchangeException(exchange));
        }
    }
View Full Code Here

            template.sendBody("direct:fail", "Hello World");
            fail("Should have thrown exception");
        } catch (RuntimeCamelException e) {
            // expected as we fail
            assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
            RollbackExchangeException rollback = assertIsInstanceOf(RollbackExchangeException.class, e.getCause().getCause());
            assertEquals("Donkey in Action", rollback.getExchange().getIn().getBody());
        }

        assertMockEndpointsSatisfied();

        int count = jdbc.queryForInt("select count(*) from books");
View Full Code Here

            // do not do anything more as we should only mark the rollback
            return;
        }

        if (message != null) {
            exchange.setException(new RollbackExchangeException(message, exchange));
        } else {
            exchange.setException(new RollbackExchangeException(exchange));
        }
    }
View Full Code Here

            return;
        }

        // throw exception to rollback
        if (message != null) {
            throw new RollbackExchangeException(message, exchange);
        } else {
            throw new RollbackExchangeException(exchange);
        }
    }
View Full Code Here

            RuntimeCamelException rce = null;

            if (exchange.isFailed() || exchange.isRollbackOnly()) {
                if (exchange.isRollbackOnly()) {
                    // rollback only so wrap an exception so we can rethrow the exception to cause rollback
                    rce = wrapRuntimeCamelException(new RollbackExchangeException(exchange));
                } else if (exchange.getException() != null) {
                    // an exception occurred while processing
                    if (endpoint.isTransferException()) {
                        // send the exception as reply, so null body and set the exception as the cause
                        body = null;
View Full Code Here

        try {
            template.sendBody("direct:fail", "Hello World");
        } catch (RuntimeCamelException e) {
            // expected as we fail
            assertIsInstanceOf(TransactedRuntimeCamelException.class, e.getCause());
            RollbackExchangeException rollback = assertIsInstanceOf(RollbackExchangeException.class, e.getCause().getCause());
            assertEquals("Donkey in Action", rollback.getExchange().getIn().getBody());
        }

        assertMockEndpointsSatisfied();

        int count = jdbc.queryForInt("select count(*) from books");
View Full Code Here

            return;
        }

        // throw exception to rollback
        if (message != null) {
            throw new RollbackExchangeException(message, exchange);
        } else {
            throw new RollbackExchangeException(exchange);
        }
    }
View Full Code Here

        try {
            template.sendBody("direct:fail", "Hello World");
        } catch (RuntimeCamelException e) {
            // expected as we fail
            assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
            RollbackExchangeException rollback = assertIsInstanceOf(RollbackExchangeException.class, e.getCause().getCause());
            assertEquals("Donkey in Action", rollback.getExchange().getIn().getBody());
        }

        assertMockEndpointsSatisfied();

        int count = jdbc.queryForInt("select count(*) from books");
View Full Code Here

TOP

Related Classes of org.apache.camel.RollbackExchangeException

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.