Package org.apache.camel

Examples of org.apache.camel.AsyncCallback


        } else {
            final UnitOfWork uow = exchange.getUnitOfWork();

            // allow unit of work to wrap callback in case it need to do some special work
            // for example the MDCUnitOfWork
            AsyncCallback async = callback;
            if (uow != null) {
                async = uow.beforeProcess(processor, exchange, callback);
            }

            // ----------------------------------------------------------
View Full Code Here


        return producer.createExchange(exchange);
    }

    public void process(final Exchange exchange) throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        boolean sync = processor.process(exchange, new AsyncCallback() {
            public void done(boolean doneSync) {
                if (!doneSync) {
                    LOG.trace("Asynchronous callback received for exchangeId: {}", exchange.getExchangeId());
                    latch.countDown();
                }
View Full Code Here

                LOG.trace("Suspending continuation of exchangeId: {}", camelExchange.getExchangeId());
                // TODO Support to set the timeout in case the Camel can't send the response back on time.
                // The continuation could be called before the suspend is called
                continuation.suspend(0);
                cxfExchange.put(SUSPENED, Boolean.TRUE);
                cxfRsConsumer.getAsyncProcessor().process(camelExchange, new AsyncCallback() {
                    public void done(boolean doneSync) {
                        // make sure the continuation resume will not be called before the suspend method in other thread
                        synchronized (continuation) {
                            LOG.trace("Resuming continuation of exchangeId: {}", camelExchange.getExchangeId());
                            // resume processing after both, sync and async callbacks
View Full Code Here

        } else {
            final UnitOfWork uow = exchange.getUnitOfWork();

            // allow unit of work to wrap callback in case it need to do some special work
            // for example the MDCUnitOfWork
            AsyncCallback async = callback;
            if (uow != null) {
                async = uow.beforeProcess(processor, exchange, callback);
            }

            // ----------------------------------------------------------
View Full Code Here

            final Endpoint e = context.getEndpoint("direct:a");
            context.start();

            for (int i = 0; i < ITERS; i++) {
                template.send(e, new SendingProcessor(i), new AsyncCallback() {
                    public void done(boolean arg0) {
                        // Do nothing here
                    }
                });
            }
View Full Code Here

        }
    }

    public void process(Exchange exchange) throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        process(exchange, new AsyncCallback() {
            public void done(boolean sync) {
                latch.countDown();
            }
        });
        latch.await();
View Full Code Here

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            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

                // must decrement the redelivery counter as we didn't process the redelivery but is
                // handling by the failure handler. So we must -1 to not let the counter be out-of-sync
                decrementRedeliveryCounter(exchange);

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

                // The line below shouldn't be needed, it is invoked by the AsyncCallback above
                //restoreExceptionOnExchange(exchange, data.handledPredicate);
                logger.log("Failed delivery for exchangeId: " + exchange.getExchangeId() + ". Handled by the failure processor: " + data.failureProcessor);
                return sync;
            }

            // should we redeliver
            if (data.redeliveryCounter > 0) {
                // okay we will give it another go so clear the exception so we can try again
                if (exchange.getException() != null) {
                    exchange.setException(null);
                }

                // wait until we should redeliver
                data.redeliveryDelay = data.currentRedeliveryPolicy.sleep(data.redeliveryDelay);
            }

            // 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

                uow.start();
            } catch (Exception e) {
                throw wrapRuntimeCamelException(e);
            }
            // return the process code where we do stop and cleanup
            return processor.process(exchange, new AsyncCallback() {
                public void done(boolean sync) {
                    // Order here matters. We need to complete the callbacks
                    // since they will likely update the exchange with
                    // some final results.
                    callback.done(sync);
View Full Code Here

        }

        final long startTime = System.nanoTime();

        if (processor instanceof AsyncProcessor) {
            return ((AsyncProcessor)processor).process(exchange, new AsyncCallback() {
                public void done(boolean doneSynchronously) {
                    if (counter != null) {
                        // convert nanoseconds to milliseconds
                        recordTime(exchange, (System.nanoTime() - startTime) / 1000000.0);
                    }
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.