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

com.github.kaizen4j.redis.connection.MessageConfig Maven / Gradle / Ivy

The newest version!
package com.github.kaizen4j.redis.connection;

import java.time.Duration;

/**
 * @author liuguowen
 */
public class MessageConfig {

    private static final long DEFAULT_MESSAGE_BODY_CACHE_SECONDS = Duration.ofHours(24).getSeconds();

    private static final long DEFAULT_MESSAGE_RETRY_DELAY_SECONDS = Duration.ofMinutes(1).getSeconds();

    private static final int DEFAULT_FETCH_SIZE = 10;

    private static final String DEFAULT_MESSAGE_BODY_CACHE_KEY_FORMAT = "MSG:BODY:%s";

    private static final String DEFAULT_MESSAGE_ACK_CACHE_KEY_FORMAT = "MSG:ACK:%s";

    /**
     * 延迟重试时间,默认:1 分钟
     */
    private long retryDelaySeconds = DEFAULT_MESSAGE_RETRY_DELAY_SECONDS;

    /**
     * 延迟消息体的缓存时间,默认:24 小时
     */
    private long messageBodyCacheSeconds = DEFAULT_MESSAGE_BODY_CACHE_SECONDS;

    /**
     * 消息获取条数,默认:10
     */
    private int fetchSize = DEFAULT_FETCH_SIZE;

    private String messageBodyFormat = DEFAULT_MESSAGE_BODY_CACHE_KEY_FORMAT;

    private String messageAckFormat = DEFAULT_MESSAGE_ACK_CACHE_KEY_FORMAT;

    public long getRetryDelaySeconds() {
        return retryDelaySeconds;
    }

    public void setRetryDelaySeconds(long retryDelaySeconds) {
        this.retryDelaySeconds = retryDelaySeconds;
    }

    public long getMessageBodyCacheSeconds() {
        return messageBodyCacheSeconds;
    }

    public void setMessageBodyCacheSeconds(long messageBodyCacheSeconds) {
        this.messageBodyCacheSeconds = messageBodyCacheSeconds;
    }

    public int getFetchSize() {
        return fetchSize;
    }

    public void setFetchSize(int fetchSize) {
        this.fetchSize = fetchSize;
    }

    public String getMessageBodyFormat() {
        return messageBodyFormat;
    }

    public void setMessageBodyFormat(String messageBodyFormat) {
        this.messageBodyFormat = messageBodyFormat;
    }

    public String getMessageAckFormat() {
        return messageAckFormat;
    }

    public void setMessageAckFormat(String messageAckFormat) {
        this.messageAckFormat = messageAckFormat;
    }

    public String getMessageBodyCacheKey(String messageId) {
        return String.format(this.messageBodyFormat, messageId);
    }

    public String getMessageAckCacheKey(String messageId) {
        return String.format(this.messageAckFormat, messageId);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy