in nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java [205:244]
public void deliver(final InternalExchange exchange) {
if (closed.get()) {
throw new ChannelClosedException();
}
// Log the exchange
if (logger.isTraceEnabled()) {
logger.trace("Channel {} delivering exchange: {}", name, exchange.display(true));
}
if (logger.isDebugEnabled()) {
logger.debug("Channel {} delivering exchange: {}", name, exchange.display(false));
}
// Handle case where the exchange has been sent synchronously
Semaphore lock = exchange.getRole() == Role.Provider ? exchange.getConsumerLock(false)
: exchange.getProviderLock(false);
if (lock != null) {
// Call listeners
for (ExchangeListener l : nmr.getListenerRegistry().getListeners(ExchangeListener.class)) {
l.exchangeDelivered(exchange);
}
lock.release();
return;
}
// Delegate processing to the executor
try {
this.executor.execute(new ExecutorAwareRunnable() {
public void run() {
process(exchange);
}
public boolean shouldRunSynchronously() {
return shouldRunSynchronously;
}
});
} catch (RejectedExecutionException e) {
if (closed.get()) {
throw new ChannelClosedException();
} else {
throw e;
}
}
}