package com.semation.jstatsd.server.messaging.disruptor;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.IgnoreExceptionHandler;
import com.lmax.disruptor.dsl.Disruptor;
import com.semation.jstatsd.StatsMessage;
import com.semation.jstatsd.server.messaging.MessageProcessor;
import com.semation.jstatsd.server.messaging.NumberOfConsumers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
class DisruptorMessageProcessor implements MessageProcessor {
    private final EventHandler<StatsMessage> eventHandler;
    private final Provider<StatsMessageParserTranslator> eventTranslatorProvider;
    private final int numberOfConsumers;
    private final Disruptor<StatsMessage> disruptor;

    private static final Logger log = LoggerFactory.getLogger(DisruptorMessageProcessor.class);

    @Inject
    public DisruptorMessageProcessor(Disruptor<StatsMessage> disruptor,
                                     EventHandler<StatsMessage> eventHandler,
                                     Provider<StatsMessageParserTranslator> eventTranslatorProvider,
                                     @NumberOfConsumers int numberOfConsumers) {
        this.disruptor = disruptor;
        this.eventHandler = eventHandler;
        this.eventTranslatorProvider = eventTranslatorProvider;
        this.numberOfConsumers = numberOfConsumers;
    }

    @Override
    public void publish(String message) {
        StatsMessageParserTranslator translator = eventTranslatorProvider.get();
        translator.setMessage(message);
        disruptor.publishEvent(translator);
    }

    @Override
    public void start() {
        log.info("Starting message processor");

        for (int i = 0; i < numberOfConsumers; i++) {
            //noinspection unchecked
            disruptor.handleEventsWith(eventHandler);
        }
        disruptor.handleExceptionsWith(new IgnoreExceptionHandler());
        disruptor.start();
        log.info("Message processor started");
    }

    @Override
    public void shutdown() {
        disruptor.shutdown();
    }
}

@@ -187,32 +187,76 @@
 r.EventHandler;%0A
+import com.lmax.disruptor.ExceptionHandler;%0A
 import com.lmax.
@@ -281,32 +281,32 @@
 ceptionHandler;%0A
-
 import com.lmax.
@@ -866,16 +866,95 @@
 uptor;%0A%0A
+    private ExceptionHandler exceptionHandler = new IgnoreExceptionHandler();%0A%0A
     priv
@@ -1579,32 +1579,191 @@
 nsumers;%0A    %7D%0A%0A
+    @Inject(optional = true)%0A    public void setExceptionHandler(ExceptionHandler exceptionHandler) %7B%0A        this.exceptionHandler = exceptionHandler;%0A    %7D%0A%0A
     @Override%0A  
@@ -2257,27 +2257,17 @@
 onsWith(
-new IgnoreE
+e
 xception
@@ -2273,18 +2273,16 @@
 nHandler
-()
 );%0A     

Add injection for exception handler