Package org.apache.camel.support

Examples of org.apache.camel.support.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


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

        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

      
        currentStream = new ByteArrayOutputStream(this.bufferSize);
       
        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

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

                onCompletion().to("mock:sync");

                from("direct:start")
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            exchange.addOnCompletion(new SynchronizationAdapter() {
                                @Override
                                public void onDone(Exchange exchange) {
                                    template.sendBody("mock:sync", "A");
                                }

                                @Override
                                public String toString() {
                                    return "A";
                                }
                            });

                            exchange.addOnCompletion(new SynchronizationAdapter() {
                                @Override
                                public void onDone(Exchange exchange) {
                                    template.sendBody("mock:sync", "B");
                                }

                                @Override
                                public String toString() {
                                    return "B";
                                }
                            });

                            exchange.addOnCompletion(new SynchronizationAdapter() {
                                @Override
                                public void onDone(Exchange exchange) {
                                    template.sendBody("mock:sync", "C");
                                }
View Full Code Here

        }

        // add on completion that invokes the policy callback on complete
        // as the Exchange can be routed async and thus we need the callback to
        // invoke when the route is completed
        exchange.addOnCompletion(new SynchronizationAdapter() {
            @Override
            public void onDone(Exchange exchange) {
                // do not invoke it if Camel is stopping as we don't want
                // the policy to start a consumer during Camel is stopping
                if (isCamelStopping(exchange.getContext())) {
View Full Code Here

                from("direct:start")
                    .process(new Processor() {
                        @Override
                        public void process(Exchange exchange) throws Exception {
                            exchange.addOnCompletion(new SynchronizationAdapter() {
                                @Override
                                public void onDone(Exchange exchange) {
                                    done = done + "A";
                                    latch.countDown();
                                }
View Full Code Here

            @Override
            public void configure() throws Exception {
                from("seda:a").process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        // should come in last
                        exchange.addOnCompletion(new SynchronizationAdapter() {
                            @Override
                            public void onDone(Exchange exchange) {
                                template.sendBody("mock:c", "onCustomCompletion");
                            }
                        });
View Full Code Here

            public void configure() throws Exception {
                onCompletion().to("mock:sync");

                from("direct:start").process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        SynchronizationAdapter adapter = new SimpleSynchronizationAdapter("mock:sync", "A");
                        exchange.addOnCompletion(adapter);

                        // should not add the adapter again as we already have it
                        if (!exchange.containsOnCompletion(adapter)) {
                            exchange.addOnCompletion(adapter);
                        }

                        adapter = new SimpleSynchronizationAdapter("mock:sync", "B");
                        exchange.addOnCompletion(adapter);

                        // now add the B again as we want to test that this also work
                        if (exchange.containsOnCompletion(adapter)) {
                            exchange.addOnCompletion(adapter);
                        }

                        // add a C that is no a SimpleSynchronizationAdapter class
                        exchange.addOnCompletion(new SynchronizationAdapter() {
                            @Override
                            public void onDone(Exchange exchange) {
                                template.sendBody("mock:sync", "C");
                            }
View Full Code Here

TOP

Related Classes of org.apache.camel.support.SynchronizationAdapter

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.