一、举例: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.