public boolean isTransacted() { UnitOfWork uow = getUnitOfWork(); if (uow != null) { return uow.isTransacted(); } else { return false; } }
public boolean containsOnCompletion(Synchronization onCompletion) { if (unitOfWork != null) { // if there is an unit of work then the completions is moved there return unitOfWork.containsSynchronization(onCompletion); } else { // check temporary completions if no unit of work yet return onCompletions != null && onCompletions.contains(onCompletion); } }
public void handoverCompletions(Exchange target) { if (onCompletions != null) { for (Synchronization onCompletion : onCompletions) { target.addOnCompletion(onCompletion); } // cleanup the temporary on completion list as they have been handed over onCompletions.clear(); onCompletions = null; } else if (unitOfWork != null) { // let unit of work handover unitOfWork.handoverSynchronization(target); } }
public void setUnitOfWork(UnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; if (unitOfWork != null && onCompletions != null) { // now an unit of work has been assigned so add the on completions // we might have registered already for (Synchronization onCompletion : onCompletions) { unitOfWork.addSynchronization(onCompletion); } // cleanup the temporary on completion list as they now have been registered // on the unit of work onCompletions.clear(); onCompletions = null; } }
/** * If the consumer needs to defer done the {@link org.apache.camel.spi.UnitOfWork} on the * processed {@link Exchange} then this method should be use to create and start the {@link * UnitOfWork} on the exchange. * * @param exchange the exchange * @return the created and started unit of work * @throws Exception is thrown if error starting the unit of work * @see #doneUoW(org.apache.camel.Exchange) */ public UnitOfWork createUoW(Exchange exchange) throws Exception { UnitOfWork uow = UnitOfWorkHelper.createUoW(exchange); exchange.setUnitOfWork(uow); uow.start(); return uow; }