Package org.apache.camel.spi

Examples of org.apache.camel.spi.UnitOfWork


        context.getProperties().put(CachedOutputStream.THRESHOLD, "16");
        deleteDirectory("./target/cachedir");
        createDirectory("./target/cachedir");

        exchange = new DefaultExchange(context);
        UnitOfWork uow = new DefaultUnitOfWork(exchange);
        exchange.setUnitOfWork(uow);
    }
View Full Code Here


        context.getProperties().put(CachedOutputStream.THRESHOLD, "16");
        deleteDirectory("./target/cachedir");
        createDirectory("./target/cachedir");

        exchange = new DefaultExchange(context);
        UnitOfWork uow = new DefaultUnitOfWork(exchange);
        exchange.setUnitOfWork(uow);
    }
View Full Code Here

        this.parent = parentUnitOfWork;
    }

    public UnitOfWork createChildUnitOfWork(Exchange childExchange) {
        // create a new child unit of work, and mark me as its parent
        UnitOfWork answer = newInstance(childExchange);
        answer.setParentUnitOfWork(this);
        return answer;
    }
View Full Code Here

    }

    @Override
    protected boolean processNext(final Exchange exchange, final AsyncCallback callback) {
        // push the current route context
        final UnitOfWork unitOfWork = exchange.getUnitOfWork();
        if (unitOfWork != null) {
            unitOfWork.pushRouteContext(routeContext);
        }

        boolean sync = processor.process(exchange, new AsyncCallback() {
            public void done(boolean doneSync) {
                try {
                    // pop the route context we just used
                    if (unitOfWork != null) {
                        unitOfWork.popRouteContext();
                    }
                } catch (Exception e) {
                    exchange.setException(e);
                } finally {
                    callback.done(doneSync);
View Full Code Here

        Exchange copy = exchange.copy();
        // do not share the unit of work
        copy.setUnitOfWork(null);
        // hand over on completion to the copy if we got any
        UnitOfWork uow = exchange.getUnitOfWork();
        if (handover && uow != null) {
            uow.handoverSynchronization(copy);
        }
        // set a correlation id so we can track back the original exchange
        copy.setProperty(Exchange.CORRELATION_ID, id);
        return copy;
    }
View Full Code Here

                exchange.setException(e);
            }
            callback.done(true);
            sync = true;
        } 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);
            }

            // we support asynchronous routing so invoke it
            sync = processor.process(exchange, async);

            // execute any after processor work (in current thread, not in the callback)
            if (uow != null) {
                uow.afterProcess(processor, exchange, callback, sync);
            }
        }

        if (LOG.isTraceEnabled()) {
            LOG.trace("Exchange processed and is continued routed {} for exchangeId: {} -> {}",
View Full Code Here

        context.getProperties().put(CachedOutputStream.THRESHOLD, "16");
        deleteDirectory("./target/cachedir");
        createDirectory("./target/cachedir");

        exchange = new DefaultExchange(context);
        UnitOfWork uow = new DefaultUnitOfWork(exchange);
        exchange.setUnitOfWork(uow);
    }
View Full Code Here

    public boolean isFailed() {
        return (hasOut() && getOut().isFault()) || getException() != null;
    }

    public boolean isTransacted() {
        UnitOfWork uow = getUnitOfWork();
        if (uow != null) {
            return uow.isTransacted();
        } else {
            return false;
        }
    }
View Full Code Here

        context.getProperties().put(CachedOutputStream.THRESHOLD, "16");
        deleteDirectory("./target/cachedir");
        createDirectory("./target/cachedir");

        exchange = new DefaultExchange(context);
        UnitOfWork uow = new DefaultUnitOfWork(exchange);
        exchange.setUnitOfWork(uow);
    }
View Full Code Here

    public static Exchange createCorrelatedCopy(Exchange exchange, boolean handover) {
        Exchange copy = exchange.copy();
        // do not share the unit of work
        copy.setUnitOfWork(null);
        // hand over on completion to the copy if we got any
        UnitOfWork uow = exchange.getUnitOfWork();
        if (handover && uow != null) {
            uow.handoverSynchronization(copy);
        }
        // set a correlation id so we can track back the original exchange
        copy.setProperty(Exchange.CORRELATION_ID, exchange.getExchangeId());
        return copy;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.UnitOfWork

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.