Package org.apache.camel

Examples of org.apache.camel.AsyncCallback


                Processor producer = pair.getProcessor();
                final Exchange subExchange = pair.getExchange();
                updateNewExchange(subExchange, i, pairs);
                exchanges.add(subExchange);
                completedExchanges.increment();
                ProcessCall call = new ProcessCall(subExchange, producer, new AsyncCallback() {
                    public void done(boolean doneSynchronously) {
                        if (streaming && aggregationStrategy != null) {
                            doAggregate(result, subExchange);
                        }
                        completedExchanges.decrement();
View Full Code Here


        int rc = pollFileOrDirectory(endpoint.getFile(), true);

        // if no files consumes and using generateEmptyExchangeWhenIdle option then process an empty exchange
        if (rc == 0 && generateEmptyExchangeWhenIdle) {
            final FileExchange exchange = endpoint.createExchange((File)null);
            getAsyncProcessor().process(exchange, new AsyncCallback() {
                public void done(boolean sync) {
                }
            });
        }
View Full Code Here

            }
            if (processStrategy.begin(endpoint, exchange, file)) {

                // Use the async processor interface so that processing of
                // the exchange can happen asynchronously
                getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        boolean failed = exchange.isFailed();
                        boolean handled = DeadLetterChannel.isFailureHandled(exchange);

                        if (LOG.isDebugEnabled()) {
View Full Code Here

                // letting onRedeliver be executed
                deliverToRedeliveryProcessor(exchange, callback, data);
            }

            // process the exchange
            boolean sync = outputAsync.process(exchange, new AsyncCallback() {
                public void done(boolean sync) {
                    // Only handle the async case...
                    if (sync) {
                        return;
                    }
View Full Code Here

            return true;
        }

        // need to declare as final
        final Channel channel = existing;
        final AsyncCallback producerCallback = new NettyProducerCallback(channel, callback);

        // setup state as attachment on the channel, so we can access the state later when needed
        channel.setAttachment(new NettyCamelState(producerCallback, exchange));

        // write body
        NettyHelper.writeBodyAsync(LOG, channel, null, body, exchange, new ChannelFutureListener() {
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                LOG.trace("Operation complete {}", channelFuture);
                if (!channelFuture.isSuccess()) {
                    // no success the set the caused exception and signal callback and break
                    exchange.setException(channelFuture.getCause());
                    producerCallback.done(false);
                    return;
                }

                // if we do not expect any reply then signal callback to continue routing
                if (!configuration.isSync()) {
                    try {
                        // should channel be closed after complete?
                        Boolean close;
                        if (ExchangeHelper.isOutCapable(exchange)) {
                            close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class);
                        } else {
                            close = exchange.getIn().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class);
                        }

                        // should we disconnect, the header can override the configuration
                        boolean disconnect = getConfiguration().isDisconnect();
                        if (close != null) {
                            disconnect = close;
                        }
                        if (disconnect) {
                            if (LOG.isTraceEnabled()) {
                                LOG.trace("Closing channel when complete at address: {}", getEndpoint().getConfiguration().getAddress());
                            }
                            NettyHelper.close(channel);
                        }
                    } finally {
                        // signal callback to continue routing
                        producerCallback.done(false);
                    }
                }
            }
        });
View Full Code Here

        if (LOG.isTraceEnabled()) {
            LOG.trace("RedeliveryProcessor " + redeliveryProcessor + " is processing Exchange: " + exchange + " before its redelivered");
        }

        AsyncProcessor afp = AsyncProcessorTypeConverter.convert(redeliveryProcessor);
        afp.process(exchange, new AsyncCallback() {
            public void done(boolean sync) {
                LOG.trace("Redelivery processor done");
                // do NOT call done on callback as this is the redelivery processor that
                // is done. we should not mark the entire exchange as done.
            }
View Full Code Here

       
        // reset cached streams so they can be read again
        MessageHelper.resetStreamCache(exchange.getIn());

        AsyncProcessor afp = AsyncProcessorTypeConverter.convert(data.failureProcessor);
        boolean sync = afp.process(exchange, new AsyncCallback() {
            public void done(boolean sync) {
                restoreExceptionOnExchange(exchange, data.handledPredicate);

                // if the fault was handled asynchronously, this should be reflected in the callback as well
                data.sync &= sync;
View Full Code Here

        }

        @Override
        public void run() {
            //only handle the real AsyncProcess the exchange
            outputAsync.process(exchange, new AsyncCallback() {
                public void done(boolean sync) {
                    // Only handle the async case...
                    if (sync) {
                        return;
                    }
View Full Code Here

            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
               
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
View Full Code Here

                EventHelper.notifyExchangeSending(exchange.getContext(), exchange, producer.getEndpoint());
            }
            // let the prepared process it, remember to begin the exchange pair
            AsyncProcessor async = AsyncProcessorConverterHelper.convert(processor);
            pair.begin();
            sync = async.process(exchange, new AsyncCallback() {
                public void done(boolean doneSync) {
                    // we are done with the exchange pair
                    pair.done();

                    // okay we are done, so notify the exchange was sent
View Full Code Here

TOP

Related Classes of org.apache.camel.AsyncCallback

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.