public boolean process(final Exchange exchange, final AsyncCallback callback) {
if (exchange.getUnitOfWork() == null) {
// If there is no existing UoW, then we should start one and
// terminate it once processing is completed for the exchange.
final DefaultUnitOfWork uow = new DefaultUnitOfWork();
exchange.setUnitOfWork(uow);
try {
uow.start();
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
// return the process code where we do stop and cleanup
return processor.process(exchange, new AsyncCallback() {
public void done(boolean sync) {
// Order here matters. We need to complete the callbacks
// since they will likely update the exchange with
// some final results.
callback.done(sync);
exchange.getUnitOfWork().done(exchange);
try {
uow.stop();
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
exchange.setUnitOfWork(null);
}