All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.extredisson.container.DelayedConsumerProcessor Maven / Gradle / Ivy

The newest version!
package com.github.lontime.extredisson.container;

import java.time.Duration;

import com.github.lontime.base.commonj.components.DelayedProcessor;
import com.github.lontime.base.logging.GLogger;
import com.github.lontime.extredisson.configuration.ConsumerOption;

/**
 * DelayedConsumerProcessor.
 * @author lontime
 * @since 1.0
 */
public class DelayedConsumerProcessor extends DelayedProcessor {

    private final ConsumerOption consumerOption;

    private RealConsumeHandler handler;

    public DelayedConsumerProcessor(ConsumerOption option) {
        this.consumerOption = option;
        this.handler = new RealConsumeHandler(option);
    }

    @Override
    protected Duration sleepTimeout() {
        return consumerOption.getInterval();
    }

    @Override
    protected Duration initialDelay() {
        return consumerOption.getWarmup();
    }

    @Override
    protected void startUp() {
        GLogger.defaults().info(getClass(), "startUp state {0}", currentState());
        if (handler != null) {
            handler.initialize();
        }
    }

    @Override
    public boolean doLoop() {
        if (handler != null) {
            return handler.doLoop();
        }
        return false;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy