Package org.apache.camel.impl

Examples of org.apache.camel.impl.DefaultConsumer


                }
            };
        }

        public Consumer createConsumer(Processor processor) throws Exception {
            return new DefaultConsumer(this, processor) {
                @Override
                protected void doStart() throws Exception {
                    processors.add(getProcessor());
                }
               
View Full Code Here


    public File getDirectory() {
        return directory;
    }

    public Consumer createConsumer(Processor processor) throws Exception {
        return new DefaultConsumer(this, processor) {
            @Override
            public void start() throws Exception {
                super.start();
                activateConsumer(this);
            }
View Full Code Here

        }
    }

    protected void dispatchToConsumer() {
        try {
            DefaultConsumer consumer;
            while ((consumer = this.consumer.get()) != null) {
                // See if there is a new record to process
                Location location = dataManager.getNextLocation(lastReadLocation);
                if (location != null) {

                    // Send it on.
                    ByteSequence read = dataManager.read(location);
                    Exchange exchange = createExchange();
                    exchange.getIn().setBody(read);
                    exchange.getIn().setHeader("journal", getEndpointUri());
                    exchange.getIn().setHeader("location", location);
                    consumer.getProcessor().process(exchange);

                    // Setting the mark makes the data manager forget about
                    // everything
                    // before that record.
                    if (LOG.isDebugEnabled()) {
View Full Code Here

    public Producer createProducer() throws Exception {
        return new DirectProducer(this);
    }

    public Consumer createConsumer(Processor processor) throws Exception {
        return new DefaultConsumer(this, processor) {
            @Override
            public void start() throws Exception {
                if (!allowMultipleConsumers && !consumers.isEmpty()) {
                    throw new IllegalStateException("Endpoint " + getEndpointUri() + " only allows 1 active consumer but you attempted to start a 2nd consumer.");
                }
View Full Code Here

                }
            };
        }

        public Consumer createConsumer(Processor processor) throws Exception {
            return new DefaultConsumer(this, processor) {
                @Override
                protected void doStart() throws Exception {
                    processors.add(getProcessor());
                }
               
View Full Code Here

                }
            };
        }

        public Consumer createConsumer(Processor processor) throws Exception {
            return new DefaultConsumer(this, processor) {
                @Override
                protected void doStart() throws Exception {
                    processors.add(getProcessor());
                }
               
View Full Code Here

                }
            };
        }

        public Consumer createConsumer(Processor processor) throws Exception {
            return new DefaultConsumer(this, processor) {
                @Override
                protected void doStart() throws Exception {
                    processors.add(getProcessor());
                }
               
View Full Code Here

            };
        }

        @Override
        public Consumer createConsumer(Processor processor) throws Exception {
            return new DefaultConsumer(this, processor) {
                @Override
                protected void doStart() throws Exception {
                    processors.add(getProcessor());
                }
               
View Full Code Here

        public void process(final Exchange exchange) throws Exception {
            final int count = getHeaderValue(exchange, HEADER_ITERATIONS);
            final int threads = getHeaderValue(exchange, HEADER_THREADS);
            PerformanceTestEndpoint endpoint = (PerformanceTestEndpoint)getEndpoint();
            if (endpoint != null) {
                final DefaultConsumer consumer = (DefaultConsumer)endpoint.getConsumer();
                ExecutorService executor = exchange.getContext().getExecutorServiceManager().newFixedThreadPool(this, "perf", threads);
                CompletionService<Exchange> tasks = new ExecutorCompletionService<Exchange>(executor);

                // StopWatch watch = new StopWatch();  // if we want to clock how long it takes
                for (int i = 0; i < count; i++) {
                    tasks.submit(new Callable<Exchange>() {
                        @Override
                        public Exchange call() throws Exception {
                            Exchange exch = ExchangeHelper.createCopy(exchange, false);
                            try {
                                consumer.getProcessor().process(exch);
                            } catch (final Exception e) {
                                exch.setException(e);
                            }
                            return exch;
                        }
View Full Code Here

    public File getDirectory() {
        return directory;
    }

    public Consumer createConsumer(Processor processor) throws Exception {
        return new DefaultConsumer(this, processor) {
            @Override
            public void start() throws Exception {
                super.start();
                activateConsumer(this);
            }
View Full Code Here

TOP

Related Classes of org.apache.camel.impl.DefaultConsumer

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.