Examples of SynchronizationAdapter


Examples of org.apache.camel.impl.SynchronizationAdapter

        final CountDownLatch latch = new CountDownLatch(1);

        template.send("direct:start", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.addOnCompletion(new SynchronizationAdapter() {
                    @Override
                    public void onDone(Exchange exchange) {
                        cause = exchange.getException();
                        latch.countDown();
                    }
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

        public void start() throws Exception {
            consumerThread = Thread.currentThread().getName();

            Exchange exchange = new DefaultExchange(context);
            exchange.setProperty(Exchange.UNIT_OF_WORK_PROCESS_SYNC, true);
            exchange.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange exchange) {
                    doneThread = Thread.currentThread().getName();
                }
            });
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

            // latch that waits until we are complete
            final CountDownLatch latch = new CountDownLatch(1);

            // we should wait for the reply so install a on completion so we know when its complete
            copy.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange response) {
                    // check for timeout, which then already would have invoked the latch
                    if (latch.getCount() == 0) {
                        if (log.isTraceEnabled()) {
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

            // latch that waits until we are complete
            final CountDownLatch latch = new CountDownLatch(1);

            // we should wait for the reply so install a on completion so we know when its complete
            copy.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange response) {
                    try {
                        ExchangeHelper.copyResults(exchange, response);
                    } finally {
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

                from("seda:async").to("direct:foo");
                from("direct:foo").process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        log.info("Received: " + exchange);

                        exchange.getUnitOfWork().addSynchronization(new SynchronizationAdapter() {
                            @Override
                            public void onComplete(Exchange exchange) {
                                completed = exchange;
                                doneLatch.countDown();
                            }
                        });

                        exchange.getUnitOfWork().addSynchronization(new SynchronizationAdapter() {
                            @Override
                            public void onFailure(Exchange exchange) {
                                failed = exchange;
                                doneLatch.countDown();
                            }
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

            // latch that waits until we are complete
            final CountDownLatch latch = new CountDownLatch(1);

            // we should wait for the reply so install a on completion so we know when its complete
            copy.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange response) {
                    // check for timeout, which then already would have invoked the latch
                    if (latch.getCount() == 0) {
                        if (log.isTraceEnabled()) {
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

            this.outputDir = exchange.getContext().getTypeConverter().convertTo(File.class, dir);
        }
       
        if (closedOnCompletion) {
            // add on completion so we can cleanup after the exchange is done such as deleting temporary files
            exchange.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange exchange) {
                    try {
                        if (fileInputStreamCache != null) {
                            fileInputStreamCache.close();
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

        if (processor == null) {
            return;
        }

        // register callback
        exchange.getUnitOfWork().addSynchronization(new SynchronizationAdapter() {
            @Override
            public void onComplete(Exchange exchange) {
                if (onFailureOnly) {
                    return;
                }
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

       
        if (exchange.getPattern() == ExchangePattern.InOnly) {
            producer.asyncSend(dispatchUri.toASCIIString(), exchange);
            reply = exchange;
        } else {
            Future<Exchange> future = producer.asyncCallback(dispatchUri.toASCIIString(), exchange, new SynchronizationAdapter());
            reply = future.get(endpoint.getConfig().getConnectionTimeout(), TimeUnit.MILLISECONDS);
        }
       
        return reply;
    }
View Full Code Here

Examples of org.apache.camel.impl.SynchronizationAdapter

            // latch that waits until we are complete
            final CountDownLatch latch = new CountDownLatch(1);

            // we should wait for the reply so install a on completion so we know when its complete
            copy.addOnCompletion(new SynchronizationAdapter() {
                @Override
                public void onDone(Exchange response) {
                    // check for timeout, which then already would have invoked the latch
                    if (latch.getCount() == 0) {
                        if (log.isTraceEnabled()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.