本文整理汇总了Java中org.apache.camel.AsyncCallback.done方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncCallback.done方法的具体用法?Java AsyncCallback.done怎么用?Java AsyncCallback.done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.AsyncCallback
的用法示例。
在下文中一共展示了AsyncCallback.done方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(Exchange exchange, AsyncCallback callback) {
if (isMarkRollbackOnlyLast()) {
// only mark the last route (current) as rollback
// this is needed when you have multiple transactions in play
exchange.setProperty(Exchange.ROLLBACK_ONLY_LAST, Boolean.TRUE);
} else {
// default to mark the entire route as rollback
exchange.setProperty(Exchange.ROLLBACK_ONLY, Boolean.TRUE);
}
if (markRollbackOnly || markRollbackOnlyLast) {
// do not do anything more as we should only mark the rollback
callback.done(true);
return true;
}
// throw exception to rollback
if (message != null) {
exchange.setException(new RollbackExchangeException(message, exchange));
} else {
exchange.setException(new RollbackExchangeException(exchange));
}
callback.done(true);
return true;
}
示例2: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
try {
exchange.removeProperties(pattern, excludePattern);
} catch (Exception e) {
exchange.setException(e);
}
callback.done(true);
return true;
}
示例3: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(Exchange exchange, AsyncCallback callback) {
LOG.trace("Process exchange: {} in the async way.", exchange);
Message in = exchange.getIn();
String methodName = in.getHeader(XmlRpcConstants.METHOD_NAME, String.class);
if (ObjectHelper.isEmpty(methodName)) {
methodName = endpoint.getDefaultMethodName();
}
if (ObjectHelper.isEmpty(methodName)) {
throw new IllegalArgumentException("CamelXmlRpcMethodName header is empty, please set the message header or defaultMethodName option on the endpoint.");
}
XmlRpcAsyncCallback xmlRpcAsyncCallback = new XmlRpcAsyncCallback(exchange, callback);
//TODO need to use the binding to handle the requests
try {
client.executeAsync(methodName, in.getBody(List.class), xmlRpcAsyncCallback);
return false;
} catch (Exception ex) {
exchange.setException(ex);
callback.done(true);
return true;
}
}
示例4: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(Exchange exchange, AsyncCallback callback) {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
int receivedCount = receivedCounter.incrementAndGet();
//only process if groupSize is set...otherwise we're in groupInterval mode
if (groupSize != null) {
if (receivedCount % groupSize == 0) {
lastLogMessage = createLogMessage(exchange, receivedCount);
log.log(lastLogMessage);
}
}
callback.done(true);
return true;
}
示例5: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
try {
Message in = exchange.getIn();
@SuppressWarnings("unchecked")
List<T> list = expression.evaluate(exchange, List.class);
Collections.sort(list, comparator);
if (exchange.getPattern().isOutCapable()) {
Message out = exchange.getOut();
out.copyFrom(in);
out.setBody(list);
} else {
in.setBody(list);
}
} catch (Exception e) {
exchange.setException(e);
}
callback.done(true);
return true;
}
示例6: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(final Exchange exchange, final AsyncCallback callback) {
List<Processor> list = getProcessors();
// too hard to do multiple async, so we do it sync
for (Processor processor : list) {
try {
Exchange copy = copyExchangeStrategy(processor, exchange);
processor.process(copy);
} catch (Throwable e) {
exchange.setException(e);
// stop on failure
break;
}
}
callback.done(true);
return true;
}
示例7: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
try {
process(exchange);
Message out = exchange.getOut();
out.copyFrom(exchange.getIn());
} catch (Exception e) {
exchange.setOut(null);
exchange.setException(e);
}
callback.done(true);
return true;
}
示例8: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
/**
* Calls the async version of the processor's process method.
* <p/>
* This implementation supports transacted {@link Exchange}s which ensure those are run in a synchronous fashion.
* See more details at {@link org.apache.camel.AsyncProcessor}.
*
* @param processor the processor
* @param exchange the exchange
* @param callback the callback
* @return <tt>true</tt> to continue execute synchronously, <tt>false</tt> to continue being executed asynchronously
* @deprecated should no longer be needed, instead invoke the process method on the {@link AsyncProcessor} directly,
* instead of using this method.
*/
@Deprecated
public static boolean process(final AsyncProcessor processor, final Exchange exchange, final AsyncCallback callback) {
boolean sync;
if (exchange.isTransacted()) {
// must be synchronized for transacted exchanges
LOG.trace("Transacted Exchange must be routed synchronously for exchangeId: {} -> {}", exchange.getExchangeId(), exchange);
try {
process(processor, exchange);
} catch (Throwable e) {
exchange.setException(e);
}
callback.done(true);
sync = true;
} else {
final UnitOfWork uow = exchange.getUnitOfWork();
// allow unit of work to wrap callback in case it need to do some special work
// for example the MDCUnitOfWork
AsyncCallback async = callback;
if (uow != null) {
async = uow.beforeProcess(processor, exchange, callback);
}
// we support asynchronous routing so invoke it
sync = processor.process(exchange, async);
// execute any after processor work (in current thread, not in the callback)
if (uow != null) {
uow.afterProcess(processor, exchange, callback, sync);
}
}
if (LOG.isTraceEnabled()) {
LOG.trace("Exchange processed and is continued routed {} for exchangeId: {} -> {}",
new Object[]{sync ? "synchronously" : "asynchronously", exchange.getExchangeId(), exchange});
}
return sync;
}
示例9: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(Exchange exchange, AsyncCallback callback) {
switch (level) {
case DEBUG:
if (log.isDebugEnabled()) {
log.debug(logMessage(exchange));
}
break;
case ERROR:
if (log.isErrorEnabled()) {
log.error(logMessage(exchange));
}
break;
case INFO:
if (log.isInfoEnabled()) {
log.info(logMessage(exchange));
}
break;
case TRACE:
if (log.isTraceEnabled()) {
log.trace(logMessage(exchange));
}
break;
case WARN:
if (log.isWarnEnabled()) {
log.warn(logMessage(exchange));
}
break;
case OFF:
break;
default:
log.error("Unknown level: " + level + " when trying to log exchange: " + logMessage(exchange));
}
callback.done(true);
return true;
}
示例10: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
Server server = null;
try {
// let the client load balancer chose which server to use
server = ribbonLoadBalancer.chooseServer();
if (server == null) {
exchange.setException(new RejectedExecutionException("No active services with name " + name));
}
} catch (Throwable e) {
exchange.setException(e);
}
if (exchange.getException() != null) {
callback.done(true);
return true;
}
String ip = server.getHost();
int port = server.getPort();
LOG.debug("Service {} active at server: {}:{}", name, ip, port);
// set selected server as header
exchange.getIn().setHeader(ServiceCallConstants.SERVER_IP, ip);
exchange.getIn().setHeader(ServiceCallConstants.SERVER_PORT, port);
exchange.getIn().setHeader(ServiceCallConstants.SERVICE_NAME, name);
// use the dynamic send processor to call the service
return processor.process(exchange, callback);
}
示例11: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public boolean process(Exchange exchange, AsyncCallback callback) {
try {
return getConsumer(exchange).getAsyncProcessor().process(exchange, callback);
} catch (Exception e) {
exchange.setException(e);
callback.done(true);
return true;
}
}
示例12: createProducer
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
public Producer createProducer() throws Exception {
return new DefaultAsyncProducer(this) {
public boolean process(Exchange exchange, AsyncCallback callback) {
onExchange(exchange);
callback.done(true);
return true;
}
};
}
示例13: sendToRecipientList
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
/**
* Sends the given exchange to the recipient list
*/
public boolean sendToRecipientList(Exchange exchange, Object recipientList, AsyncCallback callback) {
Iterator<Object> iter;
if (delimiter != null && delimiter.equalsIgnoreCase(IGNORE_DELIMITER_MARKER)) {
iter = ObjectHelper.createIterator(recipientList, null);
} else {
iter = ObjectHelper.createIterator(recipientList, delimiter);
}
RecipientListProcessor rlp = new RecipientListProcessor(exchange.getContext(), producerCache, iter, getAggregationStrategy(),
isParallelProcessing(), getExecutorService(), isShutdownExecutorService(),
isStreaming(), isStopOnException(), getTimeout(), getOnPrepare(), isShareUnitOfWork(), isParallelAggregate()) {
@Override
protected synchronized ExecutorService createAggregateExecutorService(String name) {
// use a shared executor service to avoid creating new thread pools
if (aggregateExecutorService == null) {
aggregateExecutorService = super.createAggregateExecutorService("RecipientList-AggregateTask");
}
return aggregateExecutorService;
}
};
rlp.setIgnoreInvalidEndpoints(isIgnoreInvalidEndpoints());
// start the service
try {
ServiceHelper.startService(rlp);
} catch (Exception e) {
exchange.setException(e);
callback.done(true);
return true;
}
// now let the multicast process the exchange
return rlp.process(exchange, callback);
}
示例14: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(final Exchange exchange, final AsyncCallback callback) {
try {
executor.submit(new RunCommand(exchange, callback));
} catch (Throwable t) {
exchange.setException(t);
callback.done(true);
return true;
}
return false;
}
示例15: process
import org.apache.camel.AsyncCallback; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
try {
Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
message.removeHeader(headerName);
} catch (Exception e) {
exchange.setException(e);
}
callback.done(true);
return true;
}