Package org.apache.camel

Examples of org.apache.camel.ExchangePattern


    public void populateExchangeFromCxfRequest(org.apache.cxf.message.Exchange cxfExchange,
            Exchange camelExchange) {
       
        Method method = null;
        QName operationName = null;
        ExchangePattern mep = ExchangePattern.InOut;
       
        // extract binding operation information
        BindingOperationInfo boi = camelExchange.getProperty(BindingOperationInfo.class.getName(),
                                                             BindingOperationInfo.class);
        if (boi != null) {
View Full Code Here


        this.methodInfoCache = methodInfoCache;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        BeanInvocation invocation = new BeanInvocation(method, args);
        ExchangePattern pattern = ExchangePattern.InOut;
        MethodInfo methodInfo = methodInfoCache.getMethodInfo(method);
        if (methodInfo != null) {
            pattern = methodInfo.getPattern();
        }
        Exchange exchange = new DefaultExchange(endpoint, pattern);
        exchange.getIn().setBody(invocation);

        // process the exchange
        if (LOG.isTraceEnabled()) {
            LOG.trace("Proxied method call " + method.getName() + " invoking producer: " + producer);
        }
        producer.process(exchange);

        // check if we had an exception
        Throwable fault = exchange.getException();
        if (fault != null) {
            if (fault instanceof RuntimeCamelException) {
                // if the inner cause is a runtime exception we can throw it directly
                if (fault.getCause() instanceof RuntimeException) {
                    throw (RuntimeException) ((RuntimeCamelException) fault).getCause();
                }
                throw (RuntimeCamelException) fault;
            }
            throw fault;
        }

        // do not return a reply if the method is VOID or the MEP is not OUT capable
        Class<?> to = method.getReturnType();
        if (to == Void.TYPE || !pattern.isOutCapable()) {
            return null;
        }

        // only convert if there is a body
        if (!exchange.hasOut() || exchange.getOut().getBody() == null) {
View Full Code Here

            // do nothing here
        }


        private void commitOutputMessage() throws IOException {
            ExchangePattern pattern;
            if (isOneWay) {
                pattern = ExchangePattern.InOnly;
            } else {
                pattern = ExchangePattern.InOut;
            }
View Full Code Here

        }
        return camelTemplate;
    }

    public boolean send(Message<?> message) throws Exception {
        ExchangePattern pattern;
        boolean result = false;
        if (isExpectReply()) {
            pattern = ExchangePattern.InOut;
        } else {
            pattern = ExchangePattern.InOnly;
View Full Code Here

     * @param exchange the exchange to interrogate
     * @return true if the exchange is defined as an {@link ExchangePattern} which supports
     * OUT messages
     */
    public static boolean isOutCapable(Exchange exchange) {
        ExchangePattern pattern = exchange.getPattern();
        return pattern != null && pattern.isOutCapable();
    }
View Full Code Here

    public void populateExchangeFromCxfRequest(org.apache.cxf.message.Exchange cxfExchange,
            Exchange camelExchange) {
       
        Method method = null;
        QName operationName = null;
        ExchangePattern mep = ExchangePattern.InOut;
       
        // extract binding operation information
        BindingOperationInfo boi = camelExchange.getProperty(BindingOperationInfo.class.getName(),
                                                             BindingOperationInfo.class);
        if (boi != null) {
View Full Code Here

     * @param exchange the exchange to interrogate
     * @return true if the exchange is defined as an {@link ExchangePattern} which supports
     *         OUT messages
     */
    public static boolean isOutCapable(Exchange exchange) {
        ExchangePattern pattern = exchange.getPattern();
        return pattern != null && pattern.isOutCapable();
    }
View Full Code Here

        assertMockEndpointsSatisfied();
    }


    protected void assertMessageReceivedWithPattern(String sendUri, ExchangePattern expectedPattern) throws InterruptedException {
        ExchangePattern sendPattern;
        switch (expectedPattern) {
        case InOut:
            sendPattern = ExchangePattern.InOnly;
            break;
        case InOnly:
        case RobustInOnly:
            sendPattern = ExchangePattern.InOut;
            break;
        default:
            sendPattern = ExchangePattern.InOnly;
        }

        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
        String expectedBody = "InOnlyMessage";
        resultEndpoint.expectedBodiesReceived(expectedBody);
        resultEndpoint.expectedHeaderReceived("foo", "bar");

        template.sendBodyAndHeader(sendUri, sendPattern, expectedBody, "foo", "bar");
        resultEndpoint.assertIsSatisfied();
        ExchangePattern actualPattern = resultEndpoint.getExchanges().get(0).getPattern();
        assertEquals("received exchange pattern", actualPattern, expectedPattern);
    }
View Full Code Here

            throw new IllegalStateException("SendProcessor has not been started: " + this);
        }

        // we should preserve existing MEP so remember old MEP
        // if you want to permanently to change the MEP then use .setExchangePattern in the DSL
        final ExchangePattern existingPattern = exchange.getPattern();

        // send the exchange to the destination using a producer
        producerCache.doInProducer(destination, exchange, pattern, new ProducerCallback<Exchange>() {
            public Exchange doInProducer(Producer producer, Exchange exchange, ExchangePattern pattern) throws Exception {
                exchange = configureExchange(exchange, pattern);
View Full Code Here

            throw new IllegalStateException("SendProcessor has not been started: " + this);
        }

        // we should preserve existing MEP so remember old MEP
        // if you want to permanently to change the MEP then use .setExchangePattern in the DSL
        final ExchangePattern existingPattern = exchange.getPattern();

        // send the exchange to the destination using a producer
        return producerCache.doInAsyncProducer(destination, exchange, pattern, callback, new AsyncProducerCallback() {
            public boolean doInAsyncProducer(Producer producer, AsyncProcessor asyncProducer, final Exchange exchange,
                                             ExchangePattern pattern, final AsyncCallback callback) {
View Full Code Here

TOP

Related Classes of org.apache.camel.ExchangePattern

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.