package ru.lionarius.impl.disruptor; import com.lmax.disruptor.EventHandler; import ru.lionarius.impl.CommandProcessor; public class CommandEventHandler implements EventHandler { private final CommandProcessor commandProcessor; public CommandEventHandler(CommandProcessor commandProcessor) { this.commandProcessor = commandProcessor; } @Override public void onEvent(CommandEvent event, long sequence, boolean endOfBatch) throws Exception { try { commandProcessor.processCommand(event.getCommand()); } finally { event.clear(); } } }