Package org.apache.camel

Examples of org.apache.camel.CamelException


            }

            // did we get a response
            ResponseHandler handler = (ResponseHandler) session.getHandler();
            if (handler.getCause() != null) {
                throw new CamelException("Response Handler had an exception", handler.getCause());
            } else {
                // set the result on either IN or OUT on the original exchange depending on its pattern
                if (ExchangeHelper.isOutCapable(exchange)) {
                    MinaPayloadHelper.setOut(exchange, handler.getMessage());
                } else {
View Full Code Here


            if (faultBody != null) {
                faultMessage.setBody(null); // Reset it since we are handling it.
                if (faultBody instanceof Throwable) {
                    exchange.setException((Throwable)faultBody);
                } else {
                    exchange.setException(new CamelException("Message contains fault of type "
                        + faultBody.getClass().getName() + ":\n" + faultBody));
                }
            }
        }
    }
View Full Code Here

        });
        
        try {
            channelLatch.await(configuration.getConnectTimeout(), TimeUnit.MILLISECONDS);
        } catch (InterruptedException ex) {
            throw new CamelException("Interrupted while waiting for " + "connection to "
                                     + configuration.getAddress());
        }
       

        if (!channelFuture.isDone() || !channelFuture.isSuccess()) {
View Full Code Here

            for (RouteBuilderDefinition builderRef : getBuilderRefs()) {
                RoutesBuilder routes = builderRef.createRoutes(getContext());
                if (routes != null) {
                    this.builders.add(routes);
                } else {
                    throw new CamelException("Cannot find any routes with this RouteBuilder reference: " + builderRef);
                }
            }
        }

        // install already configured routes
View Full Code Here

                    .parallelProcessing(true).streaming()
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            String string = exchange.getIn().getBody(String.class);
                            if ("Exception".equals(string)) {
                                throw new CamelException("Just want to throw exception here");
                            }
                       
                        }                   
                    }).to("mock:result");
            }
View Full Code Here

                LOG.debug("Closing session as an exception was thrown from MINA");
                session.close();
            }

            // must wrap and rethrow since cause can be of Throwable and we must only throw Exception
            throw new CamelException(cause);
        }
View Full Code Here

                assertTrue("It should be the CamelException", fault.getBody() instanceof CamelException);
                assertEquals("Fault message", "ExceptionMessage", ((CamelException)(fault.getBody())).getMessage());
            } else {
                // fault handled, exception should contain the fault
                assertNull("Fault body should be null", fault.getBody());
                CamelException faultex = (CamelException)exchange.getException();
                assertNotNull("Exception body should contain the fault", faultex);
                assertEquals("Fault message", "ExceptionMessage", faultex.getMessage());
            }
        }
    }
View Full Code Here

    public void process(Exchange exchange) {
        Integer c = exchange.getProperty(LoopProcessor.PROP_ITER_COUNT, Integer.class);
        Integer i = exchange.getProperty(LoopProcessor.PROP_ITER_INDEX, Integer.class);
        if (c == null || c.intValue() != this.count) {
            exchange.setException(new CamelException(
                "Invalid count value.  Expected " + this.count + " but was " + c));
        }
        if (i == null || i.intValue() != this.index++) {
            exchange.setException(new CamelException(
                "Invalid index value.  Expected " + this.index + " but was " + i));
        }
    }
View Full Code Here

        }

        XMPPConnection conn = getConnection();
        Iterator<String> iterator = MultiUserChat.getServiceNames(conn).iterator();
        if (!iterator.hasNext()) {
            throw new CamelException("Can not find Multi User Chat service");
        }
        String chatServer = iterator.next();
        if (LOG.isInfoEnabled()) {
            LOG.info("Detected chat server: " + chatServer);
        }
View Full Code Here

                            faultMessage.setBody(null); // Reset it since we are handling it.
                            if (faultBody instanceof Throwable) {
                                exchange.setException((Throwable)faultBody);
                            } else {
                                if (exchange.getException() == null) {                               
                                    exchange.setException(new CamelException("Message contains fault of type "
                                        + faultBody.getClass().getName() + ":\n" + faultBody));
                                }
                            }
                        }
                    }
                    callback.done(doneSynchronously);
                }               
            });
        }
       
        try {
            processor.process(exchange);
        } catch (Throwable e) {
            exchange.setException(e);
        }
       
        final Message faultMessage = exchange.getFault(false);
        if (faultMessage != null) {
            final Object faultBody = faultMessage.getBody();
            if (faultBody != null) {
                faultMessage.setBody(null); // Reset it since we are handling it.
                if (faultBody instanceof Throwable) {
                    exchange.setException((Throwable)faultBody);
                } else {
                    if (exchange.getException() == null) {
                        exchange.setException(new CamelException("Message contains fault of type "
                            + faultBody.getClass().getName() + ":\n" + faultBody));
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.camel.CamelException

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.