We had a few thoughts about it in my team too and we think having found a (temporary?) solution:
Defining our own TaskExecutor, which is actually a mix of the existing SyncTaskExecutor and ErrorHandlingTaskExecutor : a TaskExecutor that would just run the task synchronously and send any exceptions to an errorHandler.
Something that will probably look like the following class:
Code:
public class SyncErrorHandlingTaskExecutor extends SyncTaskExecutor {
private ErrorHandler errorHandler;
@Override
public void execute(Runnable task) {
Assert.notNull(task, "Runnable must not be null");
try {
task.run();
} catch (Exception e) {
getErrorHandler().handleError(e);
}
}
public ErrorHandler getErrorHandler() {
return errorHandler;
}
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
}
Then, any channel could have this task executor set to its dispatcher.
Any channel could also have a different ErrorHandler if needed.
--
Mark, Oleg,
What do you think about this solution? Do you see any obvious drawback or major issue?