一、舉例:handleExceptionsWith設置 app
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler); this
二、舉例:handleExceptionsWith方式設置須要在handler註冊前設置 spa
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
disruptor.handleExceptionsWith(new FatalExceptionHandler()); 代理
註冊handler時,經過獲取Disruptor上下文中已經設置的exceptionHandler --->> ci
if (exceptionHandler != null)
{
batchEventProcessor.setExceptionHandler(exceptionHandler);
} it
三、舉例:推薦使用setDefaultExceptionHandler方法設置exceptionHandler io
disruptor.setDefaultExceptionHandler(exceptionHandler);
disruptor.handleEventsWith(handler); event
--->> class
private ExceptionHandler<? super T> exceptionHandler = new ExceptionHandlerWrapper<T>(); sed
--->>
private ExceptionHandler<? super T> delegate = new FatalExceptionHandler();
public void switchTo(final ExceptionHandler<? super T> exceptionHandler)
{
this.delegate = exceptionHandler;
}
四、舉例:setDefaultExceptionHandler不一樣於handleExceptionsWith方法能夠在handler註冊後設置,緣由是從新設置的exceptionHandler代理,見上述代碼
disruptor.handleEventsWith(handler);
disruptor.setDefaultExceptionHandler(exceptionHandler);
五、舉例:靈活設置
disruptor.handleEventsWith(eventHandler);
disruptor.handleExceptionsFor(eventHandler).with(exceptionHandler);
--->>
com.lmax.disruptor.dsl.ExceptionHandlerSetting<T> A support class used as part of setting an exception handler for a specific event handler. For example: disruptorWizard.handleExceptionsIn(eventHandler).with(exceptionHandler); Type Parameters: <T> the type of event being handled.