use of org.apache.camel.component.routebox.strategy.RouteboxDispatcher in project camel by apache.
the class RouteboxDirectProducer method process.
public void process(Exchange exchange) throws Exception {
Exchange result;
if ((((RouteboxDirectEndpoint) getRouteboxEndpoint()).getConsumer() == null) && (getRouteboxEndpoint().getConfig().isSendToConsumer())) {
throw new CamelExchangeException("No consumers available on endpoint: " + getRouteboxEndpoint(), exchange);
} else {
LOG.debug("Dispatching to Inner Route {}", exchange);
RouteboxDispatcher dispatcher = new RouteboxDispatcher(producer);
result = dispatcher.dispatchSync(getRouteboxEndpoint(), exchange);
}
if (getRouteboxEndpoint().getConfig().isSendToConsumer()) {
((RouteboxDirectEndpoint) getRouteboxEndpoint()).getConsumer().getProcessor().process(result);
}
}
use of org.apache.camel.component.routebox.strategy.RouteboxDispatcher in project camel by apache.
the class RouteboxSedaConsumer method dispatchToInnerRoute.
private void dispatchToInnerRoute(BlockingQueue<Exchange> queue, final Exchange exchange) throws InterruptedException {
Exchange result;
if (exchange != null) {
if (isRunAllowed()) {
try {
LOG.debug("Dispatching to inner route: {}", exchange);
RouteboxDispatcher dispatcher = new RouteboxDispatcher(producer);
result = dispatcher.dispatchAsync(getRouteboxEndpoint(), exchange);
processor.process(result, new AsyncCallback() {
public void done(boolean doneSync) {
// noop
}
});
} catch (Exception e) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
}
} else {
if (LOG.isWarnEnabled()) {
LOG.warn("This consumer is stopped during polling an exchange, so putting it back on the seda queue: " + exchange);
}
queue.put(exchange);
}
}
}
use of org.apache.camel.component.routebox.strategy.RouteboxDispatcher in project camel by apache.
the class RouteboxDirectProducer method process.
public boolean process(Exchange exchange, final AsyncCallback callback) {
boolean flag = true;
if ((((RouteboxDirectEndpoint) getRouteboxEndpoint()).getConsumer() == null) && ((getRouteboxEndpoint()).getConfig().isSendToConsumer())) {
exchange.setException(new CamelExchangeException("No consumers available on endpoint: " + getRouteboxEndpoint(), exchange));
callback.done(true);
flag = true;
} else {
try {
LOG.debug("Dispatching to Inner Route {}", exchange);
RouteboxDispatcher dispatcher = new RouteboxDispatcher(producer);
exchange = dispatcher.dispatchAsync(getRouteboxEndpoint(), exchange);
if (getRouteboxEndpoint().getConfig().isSendToConsumer()) {
AsyncProcessor processor = ((RouteboxDirectEndpoint) getRouteboxEndpoint()).getConsumer().getAsyncProcessor();
flag = processor.process(exchange, callback);
}
} catch (Exception e) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
}
}
return flag;
}
Aggregations