Created
December 7, 2015 21:57
-
-
Save semenodm/1434b155217ba5427850 to your computer and use it in GitHub Desktop.
Awaiting downstream processor completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void process(final AsyncProcessor processor, final Exchange exchange) throws Exception { | |
final AsyncProcessorAwaitManager awaitManager = exchange.getContext().getAsyncProcessorAwaitManager(); | |
final CountDownLatch latch = new CountDownLatch(1); | |
boolean sync = processor.process(exchange, new AsyncCallback() { | |
public void done(boolean doneSync) { | |
if (!doneSync) { | |
awaitManager.countDown(exchange, latch); | |
} | |
} | |
@Override | |
public String toString() { | |
return "Done " + processor; | |
} | |
}); | |
if (!sync) { | |
awaitManager.await(exchange, latch); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment