Skip to content

Commit dcb4b2c

Browse files
sonus21Sonu Kumar
andauthored
Fixing #193. (#194)
* Fixing #193. * added doc * add a warning log for not running tasks * wip * Use hybrid combination of Redis and fixed rate scheduler to avoid job multiplications. * test fixes * 25% buffer * doc updated. * new user --------- Co-authored-by: Sonu Kumar <sonu@git>
1 parent f4c027e commit dcb4b2c

28 files changed

+843
-597
lines changed

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AN
8080
* Add dependency
8181
* Gradle
8282
```groovy
83-
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.13.0-RELEASE'
83+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.13.1-RELEASE'
8484
```
8585
* Maven
8686
```xml
8787
<dependency>
8888
<groupId>com.github.sonus21</groupId>
8989
<artifactId>rqueue-spring-boot-starter</artifactId>
90-
<version>2.13.0-RELEASE</version>
90+
<version>2.13.1-RELEASE</version>
9191
</dependency>
9292
```
9393
@@ -108,14 +108,14 @@ from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AN
108108
* Add Dependency
109109
* Gradle
110110
```groovy
111-
implementation 'com.github.sonus21:rqueue-spring:2.13.0-RELEASE'
111+
implementation 'com.github.sonus21:rqueue-spring:2.13.1-RELEASE'
112112
```
113113
* Maven
114114
```xml
115115
<dependency>
116116
<groupId>com.github.sonus21</groupId>
117117
<artifactId>rqueue-spring</artifactId>
118-
<version>2.13.0-RELEASE</version>
118+
<version>2.13.1-RELEASE</version>
119119
</dependency>
120120
```
121121
* Add annotation `EnableRqueue` on application config class
@@ -127,7 +127,6 @@ from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AN
127127
128128
@EnableRqueue
129129
public class Application {
130-
131130
@Bean
132131
public RedisConnectionFactory redisConnectionFactory() {
133132
// return a redis connection factory
@@ -321,13 +320,6 @@ to familiarise yourself with the project.
321320

322321
**Please format your code with Google Java formatter.**
323322

324-
```groovy
325-
// springBootVersion = '2.0.6.RELEASE'
326-
// springVersion = '5.0.10.RELEASE'
327-
// springDataVersion = '2.0.6.RELEASE'
328-
// microMeterVersion = '1.1.0'
329-
```
330-
331323
## Links
332324

333325
* Documentation: [https://sonus21.github.io/rqueue](https://sonus21.github.io/rqueue)

build.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ allprojects {
2525
}
2626

2727
ext {
28-
springBootVersion = System.getenv("SPRING_BOOT_VERSION")
29-
springVersion = System.getenv("SPRING_VERSION")
30-
springDataVersion = System.getenv("SPRING_DATA_VERSION")
31-
microMeterVersion = System.getenv("MICROMETER_VERSION")
32-
3328
springBootVersion = "3.0.1"
3429
springVersion = "6.0.3"
3530
springDataVersion = "3.0.0"
@@ -77,7 +72,7 @@ ext {
7772

7873
subprojects {
7974
group = "com.github.sonus21"
80-
version = "3.0.1-RELEASE"
75+
version = "3.1.0-RELEASE"
8176

8277
dependencies {
8378
// https://mvnrepository.com/artifact/org.springframework/spring-messaging

docs/CHANGELOG.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,37 @@ layout: default
88

99
All notable user-facing changes to this project are documented in this file.
1010

11-
## Release [3.0.1] 17-Jan-2022
11+
## Release [3.1.0] 24-June-2023
12+
{: .highlight }
13+
Migrate to this version to reduce redis resource utilization
14+
15+
This will fix an important bug happening due to task multiplications. This is causing more Redis
16+
resource usage Please check #[193]
17+
18+
## Release [2.13.1] 24-June-2023
19+
{: .highlight }
20+
Migrate to this version to reduce redis resource utilization
21+
22+
This will fix an important bug happening due to task multiplications. This is causing more Redis
23+
resource usage Please check #[193]
1224

13-
We're so excited to release Rqueue `3.0.1`. This release supports the Java 17, Spring Boot 3.x and Spring Framework 6.x
1425

26+
## Release [3.0.1] 17-Jan-2022
27+
28+
We're so excited to release Rqueue `3.0.1`. This release supports the Java 17, Spring Boot 3.x and
29+
Spring Framework 6.x
1530

1631
### [2.13.0] - 25-Dec-2022
1732

1833
### Fixes
19-
{: .highlight}
34+
35+
{: .highlight}
2036
Migrate to this version as soon as possible to avoid duplicate message consumption post deletion.
2137

2238
* Important fix for parallel message deletion or delete the message from message listener
2339
* No threads are available, improvement on message poller
2440
* Use System Zone ID for UI bottom screen
2541

26-
2742
### [2.12.0] - 14-Dec-2022
2843

2944
### Fixes
@@ -33,15 +48,14 @@ Migrate to this version as soon as possible to avoid duplicate message consumpti
3348

3449
### [2.11.1] - 18-Nov-2022
3550

36-
{: .highlight}
37-
Migrate to this version as soon as possible to avoid message build up. Messages in scheduled queue
38-
can grow if poller is failing. Workaround is to restart the application.
51+
{: .highlight}
52+
Migrate to this version as soon as possible to avoid message build up. Messages in scheduled queue
53+
can grow if poller is failing. Workaround is to restart the application.
3954

40-
* Message mover unreliability, scheduled message were not getting consumed once redis connection error occurs
55+
* Message mover unreliability, scheduled message were not getting consumed once redis connection
56+
error occurs
4157
* Upgraded Jquery version
4258

43-
44-
4559
### [2.10.2] - 16-Jul-2022
4660

4761
### Fixes
@@ -60,10 +74,10 @@ can grow if poller is failing. Workaround is to restart the application.
6074

6175
### [2.10.0] - 10-Oct-2021
6276

63-
{: .warning }
77+
{: .warning }
6478
Breaking change, if you're controlling any internal settings of Rqueue using application environment
65-
or configuration variable than application can break. We've renamed some config keys, [see](./migration#290-to-210)
66-
79+
or configuration variable than application can break. We've renamed some config
80+
keys, [see](./migration#290-to-210)
6781

6882
### Fixes
6983

@@ -235,7 +249,6 @@ Breaking change, for migration [see](./migration#1x-to-2x)
235249
REDIS with prefix `rqueue-` then it will consider version 2.
236250
- Renamed annotation field `maxJobExecutionTime` to `visibilityTimeout`
237251

238-
239252
### Added
240253

241254
- Web interface to visualize queue
@@ -294,7 +307,6 @@ Breaking change, for migration [see](./migration#1x-to-2x)
294307

295308
* The basic version of Asynchronous task execution using Redis for Spring and Spring Boot
296309

297-
298310
[1.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue/1.0-RELEASE
299311

300312
[1.1]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue/1.1-RELEASE
@@ -353,6 +365,11 @@ Breaking change, for migration [see](./migration#1x-to-2x)
353365

354366
[2.13.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.13.0-RELEASE
355367

368+
[2.13.1]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.13.1-RELEASE
369+
356370
[3.0.1]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/3.0.0-RELEASE
357371

372+
[3.1.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/3.1.0-RELEASE
373+
358374
[122]: https://github.com/sonus21/rqueue/issues/122
375+
[193]: https://github.com/sonus21/rqueue/issues/193

docs/index.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,38 +90,38 @@ the latest version in your dependency manager.
9090

9191
#### Spring Boot 2.x Setup
9292

93-
Add Rqueue Spring Boot Starter 2.9.0 and refresh your project. Once you've added the dependency,
93+
Add Rqueue Spring Boot Starter 2.13.1 and refresh your project. Once you've added the dependency,
9494
you can start sending and consuming messages.
9595

9696
* Gradle
9797
```groovy
98-
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.9.0-RELEASE'
98+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.13.1-RELEASE'
9999
```
100100
* Maven
101101
```xml
102102
<dependency>
103103
<groupId>com.github.sonus21</groupId>
104104
<artifactId>rqueue-spring-boot-starter</artifactId>
105-
<version>2.9.0-RELEASE</version>
105+
<version>2.13.1-RELEASE</version>
106106
</dependency>
107107
```
108108

109109
#### Spring Boot 3.x Setup
110110

111-
Add Rqueue Spring Boot Starter 3.0.1 and refresh your project. Once you've added the dependency,
111+
Add Rqueue Spring Boot Starter 3.1.0 and refresh your project. Once you've added the dependency,
112112
you can start sending and consuming messages.
113113

114114
* Add dependency
115115
* Gradle
116116
```groovy
117-
implementation 'com.github.sonus21:rqueue-spring-boot-starter:3.0.1-RELEASE'
117+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:3.1.0-RELEASE'
118118
```
119119
* Maven
120120
```xml
121121
<dependency>
122122
<groupId>com.github.sonus21</groupId>
123123
<artifactId>rqueue-spring-boot-starter</artifactId>
124-
<version>3.0.1-RELEASE</version>
124+
<version>3.1.0-RELEASE</version>
125125
</dependency>
126126
```
127127
@@ -140,29 +140,29 @@ in your dependency manager.
140140
141141
* Gradle
142142
```groovy
143-
implementation 'com.github.sonus21:rqueue-spring:2.9.0-RELEASE'
143+
implementation 'com.github.sonus21:rqueue-spring:2.13.1-RELEASE'
144144
```
145145
* Maven
146146
```xml
147147
<dependency>
148148
<groupId>com.github.sonus21</groupId>
149149
<artifactId>rqueue-spring</artifactId>
150-
<version>2.9.0-RELEASE</version>
150+
<version>2.13.1-RELEASE</version>
151151
</dependency>
152152
```
153153

154154
#### Spring Framework 6.x
155155

156156
* Gradle
157157
```groovy
158-
implementation 'com.github.sonus21:rqueue-spring:3.0.1-RELEASE'
158+
implementation 'com.github.sonus21:rqueue-spring:3.1.0-RELEASE'
159159
```
160160
* Maven
161161
```xml
162162
<dependency>
163163
<groupId>com.github.sonus21</groupId>
164164
<artifactId>rqueue-spring</artifactId>
165-
<version>3.0.1-RELEASE</version>
165+
<version>3.1.0-RELEASE</version>
166166
</dependency>
167167
```
168168

@@ -314,6 +314,8 @@ Rqueue is stable and production ready, it's processing millions of on messages d
314314
[![Line](static/users/line.png){: width="70" height="60" alt="Line Chat" }](https://line.me){:target="_blank" style="margin:10px"}
315315
[![Aviva](static/users/aviva.jpeg){: width="70" height="60" alt="Aviva" }](https://www.aviva.com/){:target="_blank" style="margin:10px"}
316316
[![Diamler Truck](static/users/mercedes.png){: width="80" height="60" alt="Daimler Truck (Mercedes)" }](https://www.daimlertruck.com/en){:target="_blank" style="margin:10px"}
317+
[![Vonage](static/users/vonage.png){: width="250" height="60" alt="Vonage" }](http://vonage.com){:target="_blank" style="margin:10px"}
318+
[![T-Mobile](static/users/t-mobile.svg){: width="50" height="50" alt="T Mobile" }](https://www.t-mobile.com){:target="_blank" style="margin:10px"}
317319
[![Poker Stars](static/users/pokerstars.png){: width="210" height="60" alt="PokerStars" }](https://www.pokerstarssports.eu){:target="_blank" style="margin:10px"}
318320
[![Tune You](static/users/tuneyou.png){: width="140" height="60" alt="TuneYou" }](https://tuneyou.com){:target="_blank" style="margin:10px"}
319321
[![Bit bot](static/users/bitbot.png){: width="80" height="60" alt="BitBot" }](https://bitbot.plus){:target="_blank" style="margin:10px"}

docs/message-handling/producer-consumer.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,29 @@ supported configurations.
163163
setting.
164164
* `rqueue.scheduler.auto.start=true` Rqueue scheduler also have thread pools, that handles the
165165
message. If you would like to use only event based message movement than set auto start as false.
166-
* `rqueue.scheduler.scheduled.message.thread.pool.size=5` There could be many delayed queues, in that
167-
case Rqueue has to move more messages from ZSET to LIST. In such cases, you can increase thread
168-
pool size, the number of threads used for message movement is minimum of queue count and pool
169-
size.
166+
* `rqueue.scheduler.scheduled.message.thread.pool.size=5` There could be many delayed queues, in
167+
that case Rqueue has to move more messages from ZSET to LIST. In such cases, you can increase
168+
thread pool size, the number of threads used for message movement is minimum of queue count and
169+
pool size.
170170
* `rqueue.scheduler.processing.message.thread.pool.size=1` there could be some dead message in
171171
processing queue as well, if you're seeing large number of dead messages in processing queue, then
172172
you should increase the thread pool size. Processing queue is used for at least once message
173173
delivery guarantee.
174174
* `rqueue.scheduler.scheduled.message.time.interval=5000` At what interval message should be moved
175175
from scheduled queue to normal queue. The default value is 5 seconds, that means, you can observe
176176
minimum delay of 5 seconds in delayed message consumption.
177+
* `rqueue.scheduler.max.message.count=100` Rqueue continuously move scheduled messages from
178+
processing/scheduled queue to normal queue so that we can process them asap. There are many
179+
instances when large number of messages are scheduled to be run in next 5 minutes. In such cases
180+
Rqueue can pull message from scheduled queue to normal queue at higher rate. By default, it copies
181+
100 messages from scheduled/processing queue to normal queue.
182+
* `rqueue.scheduler.max.message.mover.delay=60000` Rqueue continuously move scheduled messages from
183+
processing/scheduled queue to normal queue so that we can process them asap. Due to failure, it
184+
can load the Redis system, in such cases it uses exponential backoff to limit the damage. This
185+
time indicates maximum time for which it should wait before making Redis calls.
186+
* `rqueue.scheduler.min.message.mover.delay=200` Rqueue continuously move scheduled messages from
187+
processing/scheduled queue to normal queue so that we can process them asap. It periodically
188+
fetches the messages, the minium delay in such cases can be configured using this variable.
177189

178190
### Dead Letter Queue Consumer/Listener
179191

docs/static/users/t-mobile.svg

Lines changed: 4 additions & 0 deletions
Loading

docs/static/users/vonage.png

6.14 KB
Loading

rqueue-core/src/main/java/com/github/sonus21/rqueue/config/RqueueSchedulerConfig.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.github.sonus21.rqueue.config;
1818

19+
import com.github.sonus21.rqueue.utils.Constants;
1920
import lombok.Getter;
2021
import lombok.Setter;
2122
import org.springframework.beans.factory.annotation.Value;
@@ -68,8 +69,26 @@ public class RqueueSchedulerConfig {
6869
@Value("${rqueue.scheduler.scheduled.message.time.interval:2000}")
6970
private long scheduledMessageTimeIntervalInMilli;
7071

72+
// How long the application should wait for task termination
73+
@Value("${rqueue.scheduler.termination.wait.time:200}")
74+
private long terminationWaitTime;
7175

7276
// Maximum delay for message mover task due to failure
7377
@Value("${rqueue.scheduler.max.message.mover.delay:60000}")
7478
private long maxMessageMoverDelay;
79+
80+
// Minimum amount of time between two consecutive message move calls
81+
@Value("${rqueue.scheduler.min.message.mover.delay:100}")
82+
private long minMessageMoverDelay;
83+
84+
// Maximum number of messages that should be copied from scheduled to normal queue
85+
@Value("${rqueue.scheduler.max.message.count:100}")
86+
private long maxMessageCount;
87+
88+
public long minMessageMoveDelay() {
89+
if (minMessageMoverDelay <= 0) {
90+
return Constants.MIN_SCHEDULE_INTERVAL;
91+
}
92+
return minMessageMoverDelay;
93+
}
7594
}

0 commit comments

Comments
 (0)