Skip to content

Commit 7b49d2b

Browse files
authored
Multiple Fixes (#181)
* do not schedule a message if the job is terminated * update local metadata to handle the parallel deletion * Task rejected when threads are not available, sleep instead of poll * Display DatTime string in local time
1 parent 3c17b1f commit 7b49d2b

File tree

49 files changed

+874
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+874
-410
lines changed

.circleci/config.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ aliases:
117117
executors:
118118
rqueue-executor:
119119
machine:
120-
image: ubuntu-2004:202201-02
120+
image: ubuntu-2004:202010-01
121+
resource_class: large
121122

122123
working_directory: ~/repo
123124

@@ -267,15 +268,15 @@ workflows:
267268
- integration_test:
268269
requires:
269270
- producer_only_test
270-
- reactive_integration_test:
271+
- redis_custer_test:
271272
requires:
272273
- integration_test
273-
- redis_custer_test:
274+
- reactive_integration_test:
274275
requires:
275-
- reactive_integration_test
276+
- redis_custer_test
276277
- report_code_coverage:
277278
requires:
278-
- redis_custer_test
279+
- reactive_integration_test
279280
main_v0:
280281
jobs:
281282
- build_v0

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# [Rqueue] New and Notable Changes
22

3+
### [2.13.0] - 25-Dec-2022
4+
### Fixes
5+
* Important fix for parallel message deletion or delete the message from message listener
6+
* No threads are available, improvement on message poller
7+
* Use System Zone ID for UI bottom screen
8+
39
### [2.12.0] - 14-Dec-2022
410
### Fixes
511
* Upgraded Pebble version for CVE
@@ -319,4 +325,6 @@ Fixes:
319325

320326
[2.12.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.12.0-RELEASE
321327

328+
[2.13.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.13.0-RELEASE
329+
322330
[122]: https://github.com/sonus21/rqueue/issues/122

README.md

+29-16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ well, where all services code is in Spring.
5353
### Requirements
5454

5555
* Spring 5+
56+
* Java 1.8+
5657
* Spring boot 2+
5758
* Lettuce client for Redis cluster
5859
* Read master preference for Redis cluster
@@ -64,41 +65,44 @@ well, where all services code is in Spring.
6465
Snapshot Version: [https://s01.oss.sonatype.org/content/repositories/snapshots/com/github/sonus21/](https://s01.oss.sonatype.org/content/repositories/snapshots/com/github/sonus21/)
6566
Release Version: [Maven central](https://search.maven.org/search?q=g:com.github.sonus21)
6667

67-
#### Spring-boot
68+
---
69+
#### Spring Boot
6870

6971
* Get the latest one
7072
from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AND%20a:rqueue-spring-boot-starter)
7173
* Add dependency
7274
* Gradle
7375
```groovy
74-
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.11-RELEASE'
76+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.13.0-RELEASE'
7577
```
7678
* Maven
7779
```xml
7880
<dependency>
7981
<groupId>com.github.sonus21</groupId>
8082
<artifactId>rqueue-spring-boot-starter</artifactId>
81-
<version>2.12.0-RELEASE</version>
83+
<version>2.13.0-RELEASE</version>
8284
</dependency>
8385
```
8486
8587
No additional configurations are required, only dependency is required.
8688
89+
---
90+
8791
#### Spring framework
8892
8993
* Get the latest one
9094
from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AND%20a:rqueue-spring)
9195
* Add Dependency
9296
* Gradle
9397
```groovy
94-
implementation 'com.github.sonus21:rqueue-spring:2.12.0-RELEASE'
98+
implementation 'com.github.sonus21:rqueue-spring:2.13.0-RELEASE'
9599
```
96100
* Maven
97101
```xml
98102
<dependency>
99103
<groupId>com.github.sonus21</groupId>
100104
<artifactId>rqueue-spring</artifactId>
101-
<version>2.12.0-RELEASE</version>
105+
<version>2.13.0-RELEASE</version>
102106
</dependency>
103107
```
104108
@@ -119,11 +123,12 @@ public class Application {
119123
}
120124
```
121125

126+
---
122127
### Message publishing/Task submission
123128

124129
All messages need to be sent using `RqueueMessageEnqueuer` bean's `enqueueXXX`, `enqueueInXXX`
125130
and `enqueueAtXXX` methods. It has handful number of `enqueue`, `enqueueIn`, `enqueueAt` methods, we
126-
can use one of them based on the use case.
131+
can use any one of them based on the use case.
127132

128133
```java
129134
public class MessageService {
@@ -162,14 +167,16 @@ public class MessageService {
162167
rqueueMessageEnqueuer.enqueueWithPriority("sms-queue", priority.value(), sms);
163168
}
164169

165-
// enqueue periodic job, email should be sent every 30 seconds
170+
// Index chat every 1 minute
166171
public void sendPeriodicEmail(Email email) {
167-
rqueueMessageEnqueuer.enqueuePeriodic("email-queue", invoice, 30_000);
172+
rqueueMessageEnqueuer.enqueuePeriodic("chat-indexer", chatIndexer, 60_000);
168173
}
169174

170175
}
171176
```
172177

178+
---
179+
173180
### Worker/Consumer/Task Executor/Listener
174181

175182
Any method that's part of spring bean, can be marked as worker/message listener
@@ -223,19 +230,21 @@ public class MessageListener {
223230
}
224231
```
225232

226-
## Queue Statistics
233+
---
234+
## Dashboard
227235

228-
Micrometer based dashboard for queue
236+
Link: [http://localhost:8080/rqueue](http://localhost:8080/rqueue)
229237

230-
[![Grafana Dashboard](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png)
231238

232-
## Web
239+
[![Dashboard](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/stats-graph.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/stats-graph.png)
233240

234-
Link: [http://localhost:8080/rqueue](http://localhost:8080/rqueue)
235241

236-
#### Dashboard
242+
#### Queue Statistics
243+
244+
Micrometer based dashboard for queue
245+
246+
[![Grafana Dashboard](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png)
237247

238-
[![Dashboard](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/stats-graph.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/stats-graph.png)
239248

240249
#### Message Waiting For Execution
241250

@@ -245,6 +254,8 @@ Link: [http://localhost:8080/rqueue](http://localhost:8080/rqueue)
245254

246255
[![Jobs](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/jobs.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/jobs.png)
247256

257+
---
258+
248259
## Status
249260

250261
Rqueue is stable and production ready, it's processing 100K+ messages daily in production
@@ -264,6 +275,8 @@ PR/[issue](https://github.com/sonus21/rqueue/issues/new?template=i-m-using-rqueu
264275
<a href="https://www.chaotiinfo.cn"><img src="https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/users/chaoti-info.png" alt="CHAOTI INFO TECH(SHENZHEN)" height="60" align="middle"/></a>
265276
&nbsp;&nbsp;
266277

278+
---
279+
267280
<!---- Signing Key
268281
~/.gradle/gradle.properties file
269282
@@ -286,7 +299,7 @@ signing.secretKeyRingFile=/Users/sonu/.gnupg/secring.gpg generate this as `gpg -
286299

287300
* Please report bug,question,feature(s)
288301
to [issue](https://github.com/sonus21/rqueue/issues/new/choose) tracker.
289-
* Ask question on StackOverflow using [rqueue](https://stackoverflow.com/tags/rqueue) tag
302+
* Ask question on StackOverflow using [#rqueue](https://stackoverflow.com/tags/rqueue) tag
290303

291304
## Contribution
292305

build.gradle

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ plugins {
33
id 'com.github.kt3k.coveralls' version '2.6.3'
44
id 'nebula.optional-base' version '5.0.2'
55
id "com.adarshr.test-logger" version "2.1.1"
6+
id 'org.gradle.test-retry' version '1.0.0'
67
}
8+
79
allprojects {
810
apply plugin: 'idea'
911
apply plugin: 'java'
@@ -13,6 +15,7 @@ allprojects {
1315
apply plugin: 'jacoco'
1416
apply plugin: 'nebula.optional-base'
1517
apply plugin: 'com.adarshr.test-logger'
18+
apply plugin: 'org.gradle.test-retry'
1619

1720
sourceCompatibility = 1.8
1821
targetCompatibility = 1.8
@@ -21,6 +24,7 @@ allprojects {
2124
mavenCentral()
2225
}
2326
}
27+
2428
ext {
2529
springBootVersion = System.getenv("SPRING_BOOT_VERSION")
2630
springVersion = System.getenv("SPRING_VERSION")
@@ -70,7 +74,7 @@ ext {
7074

7175
subprojects {
7276
group = 'com.github.sonus21'
73-
version = '2.12.0-RELEASE'
77+
version = '2.13.0-RELEASE'
7478

7579
dependencies {
7680
// https://mvnrepository.com/artifact/org.springframework/spring-messaging
@@ -137,6 +141,7 @@ task codeCoverageReport(type: JacocoReport, group: 'verification', description:
137141
'com/github/sonus21/rqueue/models/response',
138142
'com/github/sonus21/rqueue/core/RqueueMessageSender*',
139143
'com/github/sonus21/rqueue/utils/PrefixLogger*',
144+
'com/github/sonus21/rqueue/utils/StackTraceUtil*',
140145
'com/github/sonus21/rqueue/core/ScheduledTaskDetail*',
141146
]
142147
)

gradle/test-runner.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Sonu Kumar
2+
* Copyright 2022 Sonu Kumar
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,4 +38,10 @@ test {
3838
html.enabled = System.getenv("CIRCLECI") != "true"
3939
html.destination = file("$buildDir/reports/junit/html")
4040
}
41+
42+
retry {
43+
failOnPassedAfterRetry = false
44+
maxFailures = 10
45+
maxRetries = 1
46+
}
4147
}

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Sonu Kumar
2+
* Copyright 2022 Sonu Kumar
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -331,4 +331,15 @@ public String getLibVersion() {
331331
public boolean isProducer() {
332332
return RqueueMode.PRODUCER.equals(getMode());
333333
}
334+
335+
public Duration getMessageDurability(Long messageLife) {
336+
if (messageLife == null || messageLife.intValue() == 0) {
337+
return Duration.ofMinutes(messageDurabilityInMinute);
338+
}
339+
Duration duration = Duration.ofMillis(2 * messageLife);
340+
if (duration.toMinutes() > messageDurabilityInMinute) {
341+
return duration;
342+
}
343+
return Duration.ofMinutes(messageDurabilityInMinute);
344+
}
334345
}

rqueue-core/src/main/java/com/github/sonus21/rqueue/core/MessageScheduler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Sonu Kumar
2+
* Copyright 2022 Sonu Kumar
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

rqueue-core/src/main/java/com/github/sonus21/rqueue/core/RqueueMessage.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Sonu Kumar
2+
* Copyright 2022 Sonu Kumar
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,9 @@
2727
import lombok.ToString;
2828
import org.springframework.messaging.MessageHeaders;
2929

30-
/** Internal message for Rqueue */
30+
/**
31+
* Internal message for Rqueue
32+
*/
3133
@Getter
3234
@Setter
3335
@ToString
@@ -43,13 +45,14 @@ public class RqueueMessage extends SerializableBase {
4345
// Queue name on which message was enqueued
4446
private String queueName;
4547
/**
46-
* JSON encoded message, this message can be converted to actual object with the help of {@link
47-
* com.github.sonus21.rqueue.core.support.RqueueMessageUtils#convertMessageToObject} method
48+
* JSON encoded message, this message can be converted to actual object with the help of
49+
* {@link com.github.sonus21.rqueue.core.support.RqueueMessageUtils#convertMessageToObject}
50+
* method
4851
*/
4952
private String message;
5053
// Any retry count used while enqueueing
5154
private Integer retryCount;
52-
// when this message was enqueued, this is in nano second
55+
// when this message was enqueued, this is in nanosecond
5356
private long queuedTime;
5457
// when this message was supposed to be processed
5558
private long processAt;
@@ -66,7 +69,9 @@ public class RqueueMessage extends SerializableBase {
6669
// period of this task, if this is a periodic task.
6770
private long period;
6871

69-
@ToString.Exclude @JsonIgnore private MessageHeaders messageHeaders;
72+
@ToString.Exclude
73+
@JsonIgnore
74+
private MessageHeaders messageHeaders;
7075

7176
@JsonIgnore
7277
public RqueueMessage updateReEnqueuedAt() {
@@ -87,14 +92,14 @@ public boolean equals(Object other) {
8792

8893
@JsonIgnore
8994
public long nextProcessAt() {
90-
if (isPeriodicTask()) {
95+
if (isPeriodic()) {
9196
return processAt + period;
9297
}
9398
throw new IllegalStateException("Only applicable for periodic message");
9499
}
95100

96101
@JsonIgnore
97-
public boolean isPeriodicTask() {
102+
public boolean isPeriodic() {
98103
return period > 0;
99104
}
100105
}

rqueue-core/src/main/java/com/github/sonus21/rqueue/core/impl/BaseMessageSender.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Sonu Kumar
2+
* Copyright 2022 Sonu Kumar
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,16 +68,7 @@ abstract class BaseMessageSender {
6868
protected Object storeMessageMetadata(
6969
RqueueMessage rqueueMessage, Long delayInMillis, boolean reactive) {
7070
MessageMetadata messageMetadata = new MessageMetadata(rqueueMessage, MessageStatus.ENQUEUED);
71-
Duration duration;
72-
if (delayInMillis != null) {
73-
duration = Duration.ofMillis(2 * delayInMillis);
74-
long minutes = duration.toMinutes();
75-
if (minutes < rqueueConfig.getMessageDurabilityInMinute()) {
76-
duration = Duration.ofMinutes(rqueueConfig.getMessageDurabilityInMinute());
77-
}
78-
} else {
79-
duration = Duration.ofMinutes(rqueueConfig.getMessageDurabilityInMinute());
80-
}
71+
Duration duration = rqueueConfig.getMessageDurability(delayInMillis);
8172
if (reactive) {
8273
return rqueueMessageMetadataService.saveReactive(messageMetadata, duration);
8374
} else {

0 commit comments

Comments
 (0)