use of org.springframework.core.task.TaskRejectedException in project gateway-dubbox by zhuzhong.
the class ThreadPoolHandlerImpl method addTask.
@Override
public Object addTask(AbstractTask task) {
try {
FutureTask<OpenApiHttpSessionBean> tsFutre = new FutureTask<OpenApiHttpSessionBean>(task);
taskExecutor.execute(tsFutre);
while (!tsFutre.isDone()) {
/*
* try { // logger.debug("waitting for result");
* TimeUnit.MICROSECONDS.sleep(200); } catch
* (InterruptedException e) { logger.error(String.format(
* "exception happend on executing task with ",
* e.getMessage())); }
*/
}
return tsFutre.get();
} catch (TaskRejectedException e) {
logger.error("the queue reached max deepth");
throw new OpenApiException(OpenApiServiceErrorEnum.SYSTEM_QUEUE_DEEPTH);
} catch (Throwable e) {
Throwable throwable = e.getCause();
if (throwable instanceof OpenApiException) {
throw (OpenApiException) throwable;
}
logger.error(String.format("exception happend on executing task with %s", e.getMessage()));
OpenApiException ex = new OpenApiException(OpenApiServiceErrorEnum.SYSTEM_BUSY, throwable);
throw ex;
}
}
use of org.springframework.core.task.TaskRejectedException in project spring-framework by spring-projects.
the class ThreadPoolTaskExecutor method submitListenable.
@Override
public ListenableFuture<?> submitListenable(Runnable task) {
ExecutorService executor = getThreadPoolExecutor();
try {
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
executor.execute(future);
return future;
} catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
}
}
use of org.springframework.core.task.TaskRejectedException in project spring-framework by spring-projects.
the class TaskExecutorAdapter method submit.
@Override
public Future<?> submit(Runnable task) {
try {
if (this.taskDecorator == null && this.concurrentExecutor instanceof ExecutorService) {
return ((ExecutorService) this.concurrentExecutor).submit(task);
} else {
FutureTask<Object> future = new FutureTask<>(task, null);
doExecute(this.concurrentExecutor, this.taskDecorator, future);
return future;
}
} catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
}
}
use of org.springframework.core.task.TaskRejectedException in project spring-framework by spring-projects.
the class TaskExecutorAdapter method submitListenable.
@Override
public ListenableFuture<?> submitListenable(Runnable task) {
try {
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
doExecute(this.concurrentExecutor, this.taskDecorator, future);
return future;
} catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
}
}
Aggregations