@@ -26,6 +26,7 @@ public class RedisquesConfiguration {
2626 private final String metricStorageName ;
2727 private final int metricRefreshPeriod ;
2828 private final int refreshPeriod ;
29+ private final int consumerLockMultiplier ;
2930 private final List <String > redisHosts ;
3031 private final List <Integer > redisPorts ;
3132 private boolean redisEnableTls ;
@@ -66,6 +67,7 @@ public class RedisquesConfiguration {
6667 private static final int DEFAULT_REDIS_RECONNECT_ATTEMPTS = 0 ;
6768 private static final int DEFAULT_REDIS_RECONNECT_DELAY_SEC = 30 ;
6869 private static final int DEFAULT_REDIS_POOL_RECYCLE_TIMEOUT_MS = 180_000 ;
70+ private static final int DEFAULT_CONSUMER_LOCK_MULTIPLIER = 2 ;
6971
7072 // We want to have more than the default of 24 max waiting requests and therefore
7173 // set the default here to infinity value. See as well:
@@ -88,6 +90,7 @@ public class RedisquesConfiguration {
8890 public static final String PROP_METRIC_STORAGE_NAME = "metric-storage-name" ;
8991 public static final String PROP_METRIC_REFRESH_PERIOD = "metric-refresh-period" ;
9092 public static final String PROP_REFRESH_PERIOD = "refresh-period" ;
93+ public static final String PROP_CONSUMER_LOCK_MULTIPLIER = "consumer-lock-multiplier" ;
9194 public static final String PROP_REDIS_HOST = "redisHost" ;
9295 public static final String PROP_REDIS_HOST_LIST = "redisHosts" ;
9396 public static final String PROP_REDIS_PORT = "redisPort" ;
@@ -148,7 +151,7 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
148151 Integer httpRequestHandlerPort , String httpRequestHandlerUserHeader ,
149152 List <QueueConfiguration > queueConfigurations , boolean enableQueueNameDecoding ) {
150153 this (address , configurationUpdatedAddress , redisPrefix , processorAddress , publishMetricsAddress , metricStorageName ,
151- metricRefreshPeriod , refreshPeriod , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
154+ metricRefreshPeriod , refreshPeriod , DEFAULT_CONSUMER_LOCK_MULTIPLIER , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
152155 RedisClientType .STANDALONE , redisAuth , null , null , false , checkInterval ,
153156 processorTimeout , processorDelayMax , httpRequestHandlerEnabled ,
154157 httpRequestHandlerAuthenticationEnabled , httpRequestHandlerPrefix , httpRequestHandlerUsername ,
@@ -173,7 +176,7 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
173176 Integer httpRequestHandlerPort , String httpRequestHandlerUserHeader ,
174177 List <QueueConfiguration > queueConfigurations , boolean enableQueueNameDecoding ) {
175178 this (address , configurationUpdatedAddress , redisPrefix , processorAddress , publishMetricsAddress , metricStorageName ,
176- metricRefreshPeriod , refreshPeriod , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
179+ metricRefreshPeriod , refreshPeriod , DEFAULT_CONSUMER_LOCK_MULTIPLIER , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
177180 RedisClientType .STANDALONE , null , redisPassword , redisUser , redisEnableTls , checkInterval ,
178181 processorTimeout , processorDelayMax , httpRequestHandlerEnabled ,
179182 httpRequestHandlerAuthenticationEnabled , httpRequestHandlerPrefix , httpRequestHandlerUsername ,
@@ -198,7 +201,32 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
198201 Integer httpRequestHandlerPort , String httpRequestHandlerUserHeader ,
199202 List <QueueConfiguration > queueConfigurations , boolean enableQueueNameDecoding ) {
200203 this (address , configurationUpdatedAddress , redisPrefix , processorAddress , publishMetricsAddress , metricStorageName ,
201- metricRefreshPeriod , refreshPeriod , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
204+ metricRefreshPeriod , refreshPeriod , DEFAULT_CONSUMER_LOCK_MULTIPLIER , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
205+ redisClientType , null , redisPassword , redisUser , redisEnableTls , checkInterval , processorTimeout ,
206+ processorDelayMax , httpRequestHandlerEnabled ,
207+ httpRequestHandlerAuthenticationEnabled , httpRequestHandlerPrefix , httpRequestHandlerUsername ,
208+ httpRequestHandlerPassword , httpRequestHandlerPort , httpRequestHandlerUserHeader , queueConfigurations ,
209+ enableQueueNameDecoding , DEFAULT_REDIS_MAX_POOL_SIZE , DEFAULT_REDIS_MAX_POOL_WAIT_SIZE ,
210+ DEFAULT_REDIS_MAX_PIPELINE_WAIT_SIZE , DEFAULT_QUEUE_SPEED_INTERVAL_SEC , DEFAULT_MEMORY_USAGE_LIMIT_PCT ,
211+ DEFAULT_MEMORY_USAGE_CHECK_INTERVAL_SEC , DEFAULT_REDIS_RECONNECT_ATTEMPTS , DEFAULT_REDIS_RECONNECT_DELAY_SEC ,
212+ DEFAULT_REDIS_POOL_RECYCLE_TIMEOUT_MS , DEFAULT_DEQUEUE_STATISTIC_REPORT_INTERVAL_SEC ,
213+ DEFAULT_REDIS_READY_CHECK_INTERVAL_MS );
214+ }
215+
216+ /**
217+ * Constructor with username and password (Redis ACL)
218+ */
219+ public RedisquesConfiguration (String address , String configurationUpdatedAddress , String redisPrefix , String processorAddress ,
220+ String publishMetricsAddress , String metricStorageName , int metricRefreshPeriod , int refreshPeriod ,
221+ int consumerLockMultiplier , String redisHost , int redisPort , RedisClientType redisClientType , String redisPassword ,
222+ String redisUser , boolean redisEnableTls , int checkInterval ,
223+ int processorTimeout , long processorDelayMax , boolean httpRequestHandlerEnabled ,
224+ boolean httpRequestHandlerAuthenticationEnabled , String httpRequestHandlerPrefix ,
225+ String httpRequestHandlerUsername , String httpRequestHandlerPassword ,
226+ Integer httpRequestHandlerPort , String httpRequestHandlerUserHeader ,
227+ List <QueueConfiguration > queueConfigurations , boolean enableQueueNameDecoding ) {
228+ this (address , configurationUpdatedAddress , redisPrefix , processorAddress , publishMetricsAddress , metricStorageName ,
229+ metricRefreshPeriod , refreshPeriod , consumerLockMultiplier , Collections .singletonList (redisHost ), Collections .singletonList (redisPort ),
202230 redisClientType , null , redisPassword , redisUser , redisEnableTls , checkInterval , processorTimeout ,
203231 processorDelayMax , httpRequestHandlerEnabled ,
204232 httpRequestHandlerAuthenticationEnabled , httpRequestHandlerPrefix , httpRequestHandlerUsername ,
@@ -212,7 +240,7 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
212240
213241 private RedisquesConfiguration (String address , String configurationUpdatedAddress , String redisPrefix , String processorAddress ,
214242 String publishMetricsAddress , String metricStorageName , int metricRefreshPeriod , int refreshPeriod ,
215- List <String > redisHosts , List <Integer > redisPorts , RedisClientType redisClientType ,
243+ int consumerLockMultiplier , List <String > redisHosts , List <Integer > redisPorts , RedisClientType redisClientType ,
216244 String redisAuth , String redisPassword , String redisUser , boolean redisEnableTls , int checkInterval ,
217245 int processorTimeout , long processorDelayMax , boolean httpRequestHandlerEnabled ,
218246 boolean httpRequestHandlerAuthenticationEnabled , String httpRequestHandlerPrefix ,
@@ -229,6 +257,7 @@ private RedisquesConfiguration(String address, String configurationUpdatedAddres
229257 this .processorAddress = processorAddress ;
230258 this .publishMetricsAddress = publishMetricsAddress ;
231259 this .refreshPeriod = refreshPeriod ;
260+ this .consumerLockMultiplier = consumerLockMultiplier ;
232261 this .redisHosts = redisHosts ;
233262 this .redisPorts = redisPorts ;
234263 this .redisClientType = redisClientType ;
@@ -326,7 +355,7 @@ public static RedisquesConfigurationBuilder with() {
326355 private RedisquesConfiguration (RedisquesConfigurationBuilder builder ) {
327356 this (builder .address , builder .configurationUpdatedAddress , builder .redisPrefix ,
328357 builder .processorAddress , builder .publishMetricsAddress , builder .metricStorageName , builder .metricRefreshPeriod ,
329- builder .refreshPeriod , builder .redisHosts , builder .redisPorts , builder .redisClientType , builder .redisAuth ,
358+ builder .refreshPeriod , builder .consumerLockMultiplier , builder . redisHosts , builder .redisPorts , builder .redisClientType , builder .redisAuth ,
330359 builder .redisPassword , builder .redisUser , builder .redisEnableTls , builder .checkInterval ,
331360 builder .processorTimeout , builder .processorDelayMax , builder .httpRequestHandlerEnabled ,
332361 builder .httpRequestHandlerAuthenticationEnabled , builder .httpRequestHandlerPrefix ,
@@ -354,6 +383,7 @@ public JsonObject asJsonObject() {
354383 obj .put (PROP_METRIC_STORAGE_NAME , getMetricStorageName ());
355384 obj .put (PROP_METRIC_REFRESH_PERIOD , getMetricRefreshPeriod ());
356385 obj .put (PROP_REFRESH_PERIOD , getRefreshPeriod ());
386+ obj .put (PROP_CONSUMER_LOCK_MULTIPLIER , getConsumerLockMultiplier ());
357387 obj .put (PROP_REDIS_HOST , getRedisHost ());
358388 obj .put (PROP_REDIS_HOST_LIST , getRedisHosts ());
359389 obj .put (PROP_REDIS_PORT , getRedisPort ());
@@ -415,6 +445,9 @@ public static RedisquesConfiguration fromJsonObject(JsonObject json) {
415445 if (json .containsKey (PROP_REFRESH_PERIOD )) {
416446 builder .refreshPeriod (json .getInteger (PROP_REFRESH_PERIOD ));
417447 }
448+ if (json .containsKey (PROP_CONSUMER_LOCK_MULTIPLIER )) {
449+ builder .consumerLockMultiplier (json .getInteger (PROP_CONSUMER_LOCK_MULTIPLIER ));
450+ }
418451 if (json .containsKey (PROP_REDIS_HOST )) {
419452 builder .redisHost (json .getString (PROP_REDIS_HOST ));
420453 }
@@ -549,6 +582,10 @@ public int getRefreshPeriod() {
549582 return refreshPeriod ;
550583 }
551584
585+ public int getConsumerLockMultiplier () {
586+ return consumerLockMultiplier ;
587+ }
588+
552589 public String getRedisHost () {
553590 return redisHosts .get (0 );
554591 }
@@ -728,6 +765,7 @@ public static class RedisquesConfigurationBuilder {
728765 private String metricStorageName ;
729766 private int metricRefreshPeriod ;
730767 private int refreshPeriod ;
768+ private int consumerLockMultiplier ;
731769 private List <String > redisHosts ;
732770 private List <Integer > redisPorts ;
733771 private boolean redisEnableTls ;
@@ -767,6 +805,7 @@ public RedisquesConfigurationBuilder() {
767805 this .processorAddress = "redisques-processor" ;
768806 this .metricRefreshPeriod = 10 ;
769807 this .refreshPeriod = 10 ;
808+ this .consumerLockMultiplier = DEFAULT_CONSUMER_LOCK_MULTIPLIER ;
770809 this .redisHosts = Collections .singletonList ("localhost" );
771810 this .redisPorts = Collections .singletonList (6379 );
772811 this .redisEnableTls = false ;
@@ -836,6 +875,11 @@ public RedisquesConfigurationBuilder refreshPeriod(int refreshPeriod) {
836875 return this ;
837876 }
838877
878+ public RedisquesConfigurationBuilder consumerLockMultiplier (int consumerLockMultiplier ) {
879+ this .consumerLockMultiplier = consumerLockMultiplier ;
880+ return this ;
881+ }
882+
839883 public RedisquesConfigurationBuilder redisHost (String redisHost ) {
840884 this .redisHosts = Collections .singletonList (redisHost );
841885 return this ;
0 commit comments