Package org.apache.camel

Examples of org.apache.camel.Message


        }
        return answer;
    }

    protected void answerWith(final Exchange exchange, final String header, final Object value) {
        final Message answer = getAnswerMessage(exchange);
        answer.setHeader(header, value);
    }
View Full Code Here


    private MethodInfo chooseMethodWithMatchingBody(Exchange exchange, Collection<MethodInfo> operationList,
                                                    List<MethodInfo> operationsWithCustomAnnotation)
        throws AmbiguousMethodCallException {
        // see if we can find a method whose body param type matches the message body
        Message in = exchange.getIn();
        Object body = in.getBody();
        if (body != null) {
            Class<?> bodyType = body.getClass();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Matching for method with a single parameter that matches type: {}", bodyType.getCanonicalName());
            }
View Full Code Here

            if (matchCounter > 1) {
                throw new AmbiguousMethodCallException(exchange, Arrays.asList(matched, matched));
            }
            if (matched != null) {
                LOG.trace("Setting converted body: {}", body);
                Message in = exchange.getIn();
                in.setBody(newBody);
                return matched;
            }
        } else {
            // if we only have a single method with custom annotations, let's use that one
            if (possibleWithCustomAnnotation.size() == 1) {
View Full Code Here

        ScriptContext context = engine.getContext();
        int scope = ScriptContext.ENGINE_SCOPE;
        context.setAttribute("context", exchange.getContext(), scope);
        context.setAttribute("camelContext", exchange.getContext(), scope);
        context.setAttribute("exchange", exchange, scope);
        Message in = exchange.getIn();
        context.setAttribute("request", in, scope);
        context.setAttribute("headers", in.getHeaders(), scope);
        context.setAttribute("body", in.getBody(), scope);
        if (exchange.hasOut()) {
            Message out = exchange.getOut();
            context.setAttribute("out", out , scope);
            context.setAttribute("response", out, scope);
        }
        // to make using properties component easier
        context.setAttribute("properties", new ScriptPropertiesFunction(exchange.getContext()), scope);
View Full Code Here

    /**
     * Prepares the redelivery counter and boolean flag for the failure handle processor
     */
    private void decrementRedeliveryCounter(Exchange exchange) {
        Message in = exchange.getIn();
        Integer counter = in.getHeader(Exchange.REDELIVERY_COUNTER, Integer.class);
        if (counter != null) {
            int prev = counter - 1;
            in.setHeader(Exchange.REDELIVERY_COUNTER, prev);
            // set boolean flag according to counter
            in.setHeader(Exchange.REDELIVERED, prev > 0 ? Boolean.TRUE : Boolean.FALSE);
        } else {
            // not redelivered
            in.setHeader(Exchange.REDELIVERY_COUNTER, 0);
            in.setHeader(Exchange.REDELIVERED, Boolean.FALSE);
        }
    }
View Full Code Here

     */
    protected DynamicQueryContext createDynamicContext(Exchange exchange) throws Exception {
        Configuration config = getConfiguration();
        DynamicQueryContext dynamicQueryContext = new DynamicQueryContext(config);

        Message in = exchange.getIn();
        Item item = null;
        if (ObjectHelper.isNotEmpty(getHeaderName())) {
            item = in.getHeader(getHeaderName(), Item.class);
        } else {
            item = in.getBody(Item.class);
        }
        if (item != null) {
            dynamicQueryContext.setContextItem(item);
        } else {
            Object body = null;
            if (ObjectHelper.isNotEmpty(getHeaderName())) {
                body = in.getHeader(getHeaderName());
            } else {
                body = in.getBody();
            }

            // the underlying input stream, which we need to close to avoid locking files or other resources
            InputStream is = null;
            try {
View Full Code Here

        this.endpoint = endpoint;
    }

    public void process(Exchange exchange) throws Exception {
        LOG.trace("Process exchange: {} in the sync way.", exchange);
        Message in = exchange.getIn();
        String operationName = in.getHeader(XmlRpcConstants.METHOD_NAME, String.class);
        //TODO need to use the binding to handle the requests
        Object result = client.execute(operationName, in.getBody(List.class));
        //TODO what if the request is one way operation
        // copy the in message header to the out message
        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
        exchange.getOut().setBody(result);
    }
View Full Code Here

        exchange.getOut().setBody(result);
    }
   
    public boolean process(Exchange exchange, AsyncCallback callback) {
        LOG.trace("Process exchange: {} in the async way.", exchange);
        Message in = exchange.getIn();
        String operationName = in.getHeader(XmlRpcConstants.METHOD_NAME, String.class);
        XmlRpcAsyncCallback xmlRpcAsyncCallback = new XmlRpcAsyncCallback(exchange, callback);
        //TODO need to use the binding to handle the requests
        try {
            client.executeAsync(operationName, in.getBody(List.class), xmlRpcAsyncCallback);
            return false;
        } catch (Exception ex) {
            exchange.setException(ex);
            callback.done(true);
            return true;
View Full Code Here

        StringBuilder sb = new StringBuilder();
        sb.append("<messages>");
        for (int i = fromIndex; i < exchanges.size() && i <= toIndex; i++) {
            Exchange exchange = exchanges.get(i);
            Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
            String xml = MessageHelper.dumpAsXml(msg, includeBody);
            sb.append("\n").append(xml);
        }
        sb.append("\n</messages>");
        return sb.toString();
View Full Code Here

        Exchange exchange = exchanges.get(index);
        if (exchange == null) {
            return null;
        }

        Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
        String xml = MessageHelper.dumpAsXml(msg, includeBody);

        return xml;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.Message

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.