@Override
    public void run()
    {
        running = true;
        if (LifecycleAware.class.isAssignableFrom(handler.getClass()))
        {
            ((LifecycleAware)handler).onStart();
        }

        T entry = null;
        long nextSequence = sequence + 1 ;
        while (running)
        {
            try
            {
                final long availableSequence = consumerBarrier.waitFor(nextSequence);
                for (; nextSequence <= availableSequence; nextSequence++)
                {
                    entry = consumerBarrier.getEntry(nextSequence);
                    handler.onAvailable(entry);
                }

                handler.onEndOfBatch();
                sequence = entry.getSequence();
            }
            catch (final AlertException ex)
            {
                // Wake up from blocking wait and check if we should continue to run
            }
            catch (final Exception ex)
            {
                exceptionHandler.handle(ex, entry);
                sequence = entry.getSequence();
                nextSequence = entry.getSequence() + 1;
            }
        }

        if (LifecycleAware.class.isAssignableFrom(handler.getClass()))
        {
            ((LifecycleAware)handler).onShutdown();
        }
    }