Package org.apache.servicemix.jbi

Examples of org.apache.servicemix.jbi.FaultException


     */
    public void fail(MessageExchange exchange, Exception error) throws MessagingException {
        if (exchange instanceof InOnly || error instanceof FaultException == false) {
            exchange.setError(error);
        } else {
            FaultException faultException = (FaultException) error;
            exchange.setFault(faultException.getFault());
        }
        getDeliveryChannel().send(exchange);
    }
View Full Code Here


                    if (exchange instanceof InOnly) {
                        // Do not use the fault has it may contain streams
                        // So just transform it to a string and send an error
                        String fault = new SourceTransformer().contentToString(me.getFault());
                        done(me);
                        fail(exchange, new FaultException(fault, null, null));
                    } else {
                        Fault fault = MessageUtil.copyFault(me);
                        MessageUtil.transferToFault(fault, exchange);
                        done(me);
                        sendSync(exchange);
                    }
                } else {
                    throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no correlation set");
                }
            // Faults must be sent back to the consumer
            } else {
                if (exchange instanceof InOnly) {
                    // Do not use the fault has it may contain streams
                    // So just transform it to a string and send an error
                    String fault = new SourceTransformer().contentToString(tme.getFault());
                    done(tme);
                    fail(exchange, new FaultException(fault, null, null));
                } else {
                    Fault fault = MessageUtil.copyFault(tme);
                    MessageUtil.transferToFault(fault, exchange);
                    done(tme);
                    sendSync(exchange);
                }
            }
        // This should not happen
        } else if (tme.getOutMessage() == null) {
            throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no correlation set");
        // This is the answer from the transformer
        } else {
            MessageExchange me = getExchangeFactory().createExchange(exchange.getPattern());
            target.configureTarget(me, getContext());
            MessageUtil.transferOutToIn(tme, me);
            sendSync(me);
            done(tme);
            if (me.getStatus() == ExchangeStatus.DONE) {
                done(exchange);
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                fail(exchange, me.getError());
            } else if (me.getFault() != null) {
                if (exchange instanceof InOnly) {
                    // Do not use the fault has it may contain streams
                    // So just transform it to a string and send an error
                    String fault = new SourceTransformer().contentToString(me.getFault());
                    done(me);
                    fail(exchange, new FaultException(fault, null, null));
                } else {
                    Fault fault = MessageUtil.copyFault(me);
                    MessageUtil.transferToFault(fault, exchange);
                    done(me);
                    sendSync(exchange);
View Full Code Here

                    MessageExchange me = (MessageExchange) store.load(consumerId);
                    if (me instanceof InOnly) {
                        // Do not use the fault has it may contain streams
                        // So just transform it to a string and send an error
                        String fault = new SourceTransformer().contentToString(exchange.getFault());
                        fail(me, new FaultException(fault, null, null));
                        done(exchange);
                    } else {
                        store.store(exchange.getExchangeId(), exchange);
                        MessageUtil.transferFaultToFault(exchange, me);
                        send(me);
View Full Code Here

        TransformComponentSupport echo = new TransformComponentSupport() {
            protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
                Fault f = exchange.createFault();
                f.setContent(new StringSource("<hello xmlns='myuri'>this is a fault</hello>"));
                f.setProperty(JBIMarshaler.SOAP_FAULT_REASON, "My reason");
                throw new FaultException(null, exchange, f);
            }
        };
        echo.setService(new QName("urn:test", "echo"));
        echo.setEndpoint("echo");
        container.activateComponent(echo, "echo");
View Full Code Here

        TransformComponentSupport echo = new TransformComponentSupport() {
            protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
                Fault f = exchange.createFault();
                f.setContent(new StringSource("<hello xmlns='myuri'>this is a fault</hello>"));
                f.setProperty(JBIMarshaler.SOAP_FAULT_REASON, "My reason");
                throw new FaultException(null, exchange, f);
            }
        };
        echo.setService(new QName("urn:test", "echo"));
        echo.setEndpoint("echo");
        container.activateComponent(echo, "echo");
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.FaultException

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.