public void configure() throws Exception {
onCompletion().to("mock:sync");
from("direct:start").process(new Processor() {
public void process(Exchange exchange) throws Exception {
SynchronizationAdapter adapter = new SimpleSynchronizationAdapter("mock:sync", "A");
exchange.addOnCompletion(adapter);
// should not add the adapter again as we already have it
if (!exchange.containsOnCompletion(adapter)) {
exchange.addOnCompletion(adapter);
}
adapter = new SimpleSynchronizationAdapter("mock:sync", "B");
exchange.addOnCompletion(adapter);
// now add the B again as we want to test that this also work
if (exchange.containsOnCompletion(adapter)) {
exchange.addOnCompletion(adapter);
}
// add a C that is no a SimpleSynchronizationAdapter class
exchange.addOnCompletion(new SynchronizationAdapter() {
@Override
public void onDone(Exchange exchange) {
template.sendBody("mock:sync", "C");
}