public Object consume() {
        int index = consumed - base;
        if (index < 0) {
            logger.debug("negative index {} for base {}.", index, base);
            index += size;
            if (index < 0) {
                logger.error("remove id out of window.");
                return null;
            }
        }
        Object result = buffer.get(index);
        if (result == null) {
            logger.debug("cell {} is empty. base {}.", index, base);
            return null;
        }
        if (!buffer.compareAndSet(index, result, null)) {
            logger.error("index {} changed  to {}", index, buffer.get(index));
        }
        ++consumed;
        used.decrementAndGet();
        logger.debug("global id {} of message {}.", consumed, result);
        return result;
    }