Class QueueConfigsReader
- java.lang.Object
-
- ru.yoomoney.tech.dbqueue.settings.QueueConfigsReader
-
@ThreadSafe public class QueueConfigsReader extends java.lang.ObjectReads queue configuration from file.File should be a regular
Propertiesfile, so format is 'queue-prefix.key.innerkey=val'. Where actual name of 'queue-prefix' is defined in constructor. Settings with other prefixes are ignored.- Key names of queue settings should contain alphanumeric characters, dashes and underscores.
- Duration settings must be in ISO-8601. see
Duration.parse(CharSequence)
Full configuration looks like:
# see
SETTING_TABLEqueue-prefix.testQueue.table=foo # seeSETTING_BETWEEN_TASK_TIMEOUTqueue-prefix.testQueue.between-task-timeout=PT0.1S # seeSETTING_NO_TASK_TIMEOUTqueue-prefix.testQueue.no-task-timeout=PT1S # seeSETTING_FATAL_CRASH_TIMEOUTqueue-prefix.testQueue.fatal-crash-timeout=PT5S # seeSETTING_THREAD_COUNTqueue-prefix.testQueue.thread-count=3 # seeSETTING_RETRY_TYPE# values are: #VALUE_TASK_RETRY_TYPE_ARITHMETIC#VALUE_TASK_RETRY_TYPE_GEOMETRIC#VALUE_TASK_RETRY_TYPE_LINEARqueue-prefix.testQueue.retry-type=linear # seeSETTING_RETRY_INTERVALqueue-prefix.testQueue.retry-interval=PT30S # seeSETTING_REENQUEUE_RETRY_TYPE# values are: #VALUE_REENQUEUE_RETRY_TYPE_MANUAL#VALUE_REENQUEUE_RETRY_TYPE_FIXED#VALUE_REENQUEUE_RETRY_TYPE_SEQUENTIAL#VALUE_REENQUEUE_RETRY_TYPE_ARITHMETIC#VALUE_REENQUEUE_RETRY_TYPE_GEOMETRIC# #VALUE_REENQUEUE_RETRY_TYPE_MANUALis used by default queue-prefix.testQueue.reenqueue-retry-type=fixed # seeSETTING_REENQUEUE_RETRY_DELAY# Required whenSETTING_REENQUEUE_RETRY_TYPEis set to 'fixed' queue-prefix.testQueue.reenqueue-retry-delay=PT10S # seeSETTING_REENQUEUE_RETRY_PLAN# Required whenSETTING_REENQUEUE_RETRY_TYPEis set to 'sequential' queue-prefix.testQueue.reenqueue-retry-plan=PT1S,PT2S,PT3S # seeSETTING_REENQUEUE_RETRY_INITIAL_DELAY# PT1S is used by default. queue-prefix.testQueue.reenqueue-retry-initial-delay=PT10S # seeSETTING_REENQUEUE_RETRY_STEP# PT2S is used by default. queue-prefix.testQueue.reenqueue-retry-step=PT2S # seeSETTING_REENQUEUE_RETRY_RATIO# 2 is used by default. queue-prefix.testQueue.reenqueue-retry-ratio=3 # seeSETTING_PROCESSING_MODE# values are: #VALUE_PROCESSING_MODE_SEPARATE_TRANSACTIONS#VALUE_PROCESSING_MODE_USE_EXTERNAL_EXECUTOR#VALUE_PROCESSING_MODE_WRAP_IN_TRANSACTIONqueue-prefix.testQueue.processing-mode=use-external-executor # seeSETTING_ADDITIONAL# seeQueueSettings.getExtSettings()queue-prefix.testQueue.additional-settings.custom-val=custom-key # you can define custom settings to use it in enqueueing or processing queue-prefix.testQueue.additional-settings.custom=val1Where 'testQueue' is name of a queue you apply configuration to.
- Since:
- 22.08.2017
- See Also:
QueueSettings,QueueLocation,FailRetryType,ProcessingMode,QueueConfig
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description QueueConfigsReader(java.util.List<java.nio.file.Path> configPaths, java.lang.String settingsPrefix)ConstructorQueueConfigsReader(java.util.List<java.nio.file.Path> configPaths, java.lang.String settingsPrefix, java.util.function.Supplier<ProcessingSettings.Builder> defaultProcessingSettings, java.util.function.Supplier<PollSettings.Builder> defaultPollSettings, java.util.function.Supplier<FailureSettings.Builder> defaultFailureSettings, java.util.function.Supplier<ReenqueueSettings.Builder> defaultReenqueueSettings)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.nio.file.Path>getConfigPaths()Get paths to queue configsjava.util.List<QueueConfig>parse()Try to parse queues configurations.
-
-
-
Field Detail
-
VALUE_TASK_RETRY_TYPE_GEOMETRIC
public static final java.lang.String VALUE_TASK_RETRY_TYPE_GEOMETRIC
Representation ofFailRetryType.GEOMETRIC_BACKOFF- See Also:
- Constant Field Values
-
VALUE_TASK_RETRY_TYPE_ARITHMETIC
public static final java.lang.String VALUE_TASK_RETRY_TYPE_ARITHMETIC
Representation ofFailRetryType.ARITHMETIC_BACKOFF- See Also:
- Constant Field Values
-
VALUE_TASK_RETRY_TYPE_LINEAR
public static final java.lang.String VALUE_TASK_RETRY_TYPE_LINEAR
Representation ofFailRetryType.LINEAR_BACKOFF- See Also:
- Constant Field Values
-
VALUE_REENQUEUE_RETRY_TYPE_MANUAL
public static final java.lang.String VALUE_REENQUEUE_RETRY_TYPE_MANUAL
Representation ofReenqueueRetryType.MANUAL- See Also:
- Constant Field Values
-
VALUE_REENQUEUE_RETRY_TYPE_FIXED
public static final java.lang.String VALUE_REENQUEUE_RETRY_TYPE_FIXED
Representation ofReenqueueRetryType.FIXED- See Also:
- Constant Field Values
-
VALUE_REENQUEUE_RETRY_TYPE_SEQUENTIAL
public static final java.lang.String VALUE_REENQUEUE_RETRY_TYPE_SEQUENTIAL
Representation ofReenqueueRetryType.SEQUENTIAL- See Also:
- Constant Field Values
-
VALUE_REENQUEUE_RETRY_TYPE_ARITHMETIC
public static final java.lang.String VALUE_REENQUEUE_RETRY_TYPE_ARITHMETIC
Representation ofReenqueueRetryType.ARITHMETIC- See Also:
- Constant Field Values
-
VALUE_REENQUEUE_RETRY_TYPE_GEOMETRIC
public static final java.lang.String VALUE_REENQUEUE_RETRY_TYPE_GEOMETRIC
Representation ofReenqueueRetryType.GEOMETRIC- See Also:
- Constant Field Values
-
VALUE_PROCESSING_MODE_USE_EXTERNAL_EXECUTOR
public static final java.lang.String VALUE_PROCESSING_MODE_USE_EXTERNAL_EXECUTOR
Representation ofProcessingMode.USE_EXTERNAL_EXECUTOR- See Also:
- Constant Field Values
-
VALUE_PROCESSING_MODE_WRAP_IN_TRANSACTION
public static final java.lang.String VALUE_PROCESSING_MODE_WRAP_IN_TRANSACTION
Representation ofProcessingMode.WRAP_IN_TRANSACTION- See Also:
- Constant Field Values
-
VALUE_PROCESSING_MODE_SEPARATE_TRANSACTIONS
public static final java.lang.String VALUE_PROCESSING_MODE_SEPARATE_TRANSACTIONS
Representation ofProcessingMode.SEPARATE_TRANSACTIONS- See Also:
- Constant Field Values
-
SETTING_PROCESSING_MODE
public static final java.lang.String SETTING_PROCESSING_MODE
Representation ofProcessingSettings.getProcessingMode()- See Also:
- Constant Field Values
-
SETTING_RETRY_TYPE
public static final java.lang.String SETTING_RETRY_TYPE
Representation ofFailureSettings.getRetryType()- See Also:
- Constant Field Values
-
SETTING_RETRY_INTERVAL
public static final java.lang.String SETTING_RETRY_INTERVAL
Representation ofFailureSettings.getRetryInterval()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_TYPE
public static final java.lang.String SETTING_REENQUEUE_RETRY_TYPE
Representation ofReenqueueSettings.getRetryType()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_PLAN
public static final java.lang.String SETTING_REENQUEUE_RETRY_PLAN
Representation ofReenqueueSettings.getSequentialPlanOrThrow()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_DELAY
public static final java.lang.String SETTING_REENQUEUE_RETRY_DELAY
Representation ofReenqueueSettings.getFixedDelayOrThrow()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_INITIAL_DELAY
public static final java.lang.String SETTING_REENQUEUE_RETRY_INITIAL_DELAY
Representation ofReenqueueSettings.getInitialDelayOrThrow()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_STEP
public static final java.lang.String SETTING_REENQUEUE_RETRY_STEP
Representation ofReenqueueSettings.getArithmeticStepOrThrow()- See Also:
- Constant Field Values
-
SETTING_REENQUEUE_RETRY_RATIO
public static final java.lang.String SETTING_REENQUEUE_RETRY_RATIO
Representation ofReenqueueSettings.getGeometricRatioOrThrow()- See Also:
- Constant Field Values
-
SETTING_THREAD_COUNT
public static final java.lang.String SETTING_THREAD_COUNT
Representation ofProcessingSettings.getThreadCount()- See Also:
- Constant Field Values
-
SETTING_FATAL_CRASH_TIMEOUT
public static final java.lang.String SETTING_FATAL_CRASH_TIMEOUT
Representation ofPollSettings.getFatalCrashTimeout()- See Also:
- Constant Field Values
-
SETTING_BETWEEN_TASK_TIMEOUT
public static final java.lang.String SETTING_BETWEEN_TASK_TIMEOUT
Representation ofPollSettings.getBetweenTaskTimeout()- See Also:
- Constant Field Values
-
SETTING_NO_TASK_TIMEOUT
public static final java.lang.String SETTING_NO_TASK_TIMEOUT
Representation ofPollSettings.getNoTaskTimeout()- See Also:
- Constant Field Values
-
SETTING_TABLE
public static final java.lang.String SETTING_TABLE
Representation ofQueueLocation.getTableName()- See Also:
- Constant Field Values
-
SETTING_ID_SEQUENCE
public static final java.lang.String SETTING_ID_SEQUENCE
Representation ofQueueLocation.getIdSequence()- See Also:
- Constant Field Values
-
SETTING_ADDITIONAL
public static final java.lang.String SETTING_ADDITIONAL
Representation ofQueueSettings.getExtSettings()- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QueueConfigsReader
public QueueConfigsReader(@Nonnull java.util.List<java.nio.file.Path> configPaths, @Nonnull java.lang.String settingsPrefix)Constructor- Parameters:
configPaths- files to read configuration from.settingsPrefix- prefix that will be used for queue settings.
-
QueueConfigsReader
public QueueConfigsReader(@Nonnull java.util.List<java.nio.file.Path> configPaths, @Nonnull java.lang.String settingsPrefix, @Nonnull java.util.function.Supplier<ProcessingSettings.Builder> defaultProcessingSettings, @Nonnull java.util.function.Supplier<PollSettings.Builder> defaultPollSettings, @Nonnull java.util.function.Supplier<FailureSettings.Builder> defaultFailureSettings, @Nonnull java.util.function.Supplier<ReenqueueSettings.Builder> defaultReenqueueSettings)Constructor- Parameters:
configPaths- files to read configuration from.settingsPrefix- prefix that will be used for queue settings.defaultProcessingSettings- defaultProcessingSettingsdefaultPollSettings- defaultPollSettingsdefaultFailureSettings- defaultFailureSettingsdefaultReenqueueSettings- defaultReenqueueSettings
-
-
Method Detail
-
getConfigPaths
@Nonnull public java.util.List<java.nio.file.Path> getConfigPaths()
Get paths to queue configs- Returns:
- paths to queue configs
-
parse
@Nonnull public java.util.List<QueueConfig> parse()
Try to parse queues configurations.- Returns:
- parsed queue configurations
-
-