Skip to content

Commit d5520ae

Browse files
authored
Display Completed Jobs (#109)
* class and variables renamed to schedule* from delay* * display complete jobs in dashboard * fix message move message count #105 * Fixed #112 * * doc updated * README updates * Potential cross slot error in rename * remove doble tagging * fixes for url web prefix * added filter to select number of days/months/weeks to select data
1 parent 2fdbbe7 commit d5520ae

File tree

187 files changed

+2807
-1559
lines changed

Some content is hidden

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

187 files changed

+2807
-1559
lines changed

.travis.yml

-63
This file was deleted.

CHANGELOG.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
# [Rqueue] New and Notable Changes
22

3+
### [2.10.0] - 10-Oct-2021
4+
5+
### Fixes
6+
7+
* Fixes for post processor calls (post processor calls were not made)
8+
* Fixes message move message count (by default 1000 messages are moved)
9+
* Potential issue in rename collection
10+
* More than one (-) sign in the dashboard
11+
* Fixes for server context path. Rqueue end points would be served relative to x-forwarded-prefix/server.servlet.context-path
12+
13+
### Features
14+
15+
* Display completed jobs in the dashboard
16+
* Option to choose number of days in the chart
17+
ReactiveWebViewTest
318
### [2.9.0] - 30-Jul-2021
19+
420
### Fixes
5-
* Option to add rqueue web url prefix, the prefix is configured from application.properties file using
6-
`rqueue.web.url.prefix=/my-application/`, now rqueue dashboard would be served
7-
at `/my-application/rquque` instead of `/rqueue`, the configuration has higher priority than the
8-
HTTP request header `x-forwarded-prefix`.
9-
21+
22+
* Option to add rqueue web url prefix, the prefix is configured from application.properties file
23+
using `rqueue.web.url.prefix=/my-application/`, now rqueue dashboard would be served
24+
at `/my-application/rquque` instead of `/rqueue`, the configuration has higher priority than the
25+
HTTP request header `x-forwarded-prefix`.
1026
* Custom message converter is not working
1127
* RedisCommandExecutionException : command arguments must be strings or integers
1228

@@ -196,7 +212,7 @@ Fixes:
196212
### Fixed
197213

198214
* An issue in the scheduler that's always scheduling job at the delay of 5 seconds. (this leads to
199-
messages are not copied from delayed queue to main queue on high load)
215+
messages are not copied from scheduled queue to main queue on high load)
200216

201217
## [1.2] - 03-Nov-2019
202218

@@ -255,3 +271,5 @@ Fixes:
255271
[2.8.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.8.0-RELEASE
256272

257273
[2.9.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.9.0-RELEASE
274+
275+
[2.10.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.10.0-RELEASE

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
22
<img align="left" src="https://raw.githubusercontent.com/sonus21/rqueue/master/rqueue-core/src/main/resources/public/rqueue/img/android-chrome-192x192.png" alt="Rqueue Logo" width="90">
3-
<h1 style="float:left">Rqueue: Redis Queue, Task Queue, Delayed Queue for Spring and Spring Boot</h1>
3+
<h1 style="float:left">Rqueue: Redis Queue, Task Queue, Scheduled Queue for Spring and Spring Boot</h1>
44
</div>
55

66
[![Build Status](https://circleci.com/gh/sonus21/rqueue/tree/master.svg?style=shield)](https://circleci.com/gh/sonus21/rqueue/tree/master)
@@ -32,7 +32,7 @@ well, where all services code is in Spring.
3232
* **Automatic message serialization and deserialization**
3333
* **Message Multicasting** : Call multiple message listeners on every message
3434
* **Batch Message Polling** : Fetch multiple messages from Redis at once
35-
* **Metrics** : In flight messages, waiting for consumption and delayed messages
35+
* **Metrics** : In flight messages, waiting for consumption and scheduled messages
3636
* **Competing Consumers** : multiple messages can be consumed in parallel by different
3737
workers/listeners.
3838
* **Concurrency** : Concurrency of any listener can be configured
@@ -71,14 +71,14 @@ Release Version: [Maven central](https://search.maven.org/search?q=g:com.github.
7171
* Add dependency
7272
* Gradle
7373
```groovy
74-
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.9.0-RELEASE'
74+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.10.0-RELEASE'
7575
```
7676
* Maven
7777
```xml
7878
<dependency>
7979
<groupId>com.github.sonus21</groupId>
8080
<artifactId>rqueue-spring-boot-starter</artifactId>
81-
<version>2.9.0-RELEASE</version>
81+
<version>2.10.0-RELEASE</version>
8282
</dependency>
8383
```
8484
@@ -91,14 +91,14 @@ Release Version: [Maven central](https://search.maven.org/search?q=g:com.github.
9191
* Add Dependency
9292
* Gradle
9393
```groovy
94-
implementation 'com.github.sonus21:rqueue-spring:2.9.0-RELEASE'
94+
implementation 'com.github.sonus21:rqueue-spring:2.10.0-RELEASE'
9595
```
9696
* Maven
9797
```xml
9898
<dependency>
9999
<groupId>com.github.sonus21</groupId>
100100
<artifactId>rqueue-spring</artifactId>
101-
<version>2.9.0-RELEASE</version>
101+
<version>2.10.0-RELEASE</version>
102102
</dependency>
103103
```
104104

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ext {
7070

7171
subprojects {
7272
group = 'com.github.sonus21'
73-
version = '2.9.0-RELEASE'
73+
version = '2.10.0-RELEASE'
7474

7575
dependencies {
7676
// https://mvnrepository.com/artifact/org.springframework/spring-messaging

rqueue-core/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ext.projectDescription = 'Asynchronous and delayed task executor'
1+
ext.projectDescription = 'Asynchronous and scheduled task executor'
22
ext.name = 'Rqueue Core Java'
33
buildscript {
44
apply from: "${rootDir}/gradle/code-signing.gradle"

rqueue-core/src/main/java/com/github/sonus21/rqueue/annotation/RqueueListener.java

+4-14
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* public class MessageListener {
4141
* &#64;RqueueListener(
4242
* value="${job.queue}",
43-
* delayedQueue="true",
4443
* numRetries="3",
4544
* deadLetterQueue="#{job.dead.letter.queue}",
4645
* visibilityTimeout="30*60*1000")
@@ -62,16 +61,6 @@
6261
*/
6362
String[] value() default {};
6463

65-
/**
66-
* All queues are considered delayed for fast recovery, it can not be disabled even by setting
67-
* this to false.
68-
*
69-
* @deprecated since 2.0
70-
* @return whether it's delayed queue or not.
71-
*/
72-
@Deprecated
73-
String delayedQueue() default "true";
74-
7564
/**
7665
* Number of times a message should be retried before it can be discarded or send it to dead
7766
* letter queue in case of consecutive failures. This is a global value for a consumer, each
@@ -99,8 +88,9 @@
9988
String deadLetterQueue() default "";
10089

10190
/**
102-
* By default messages sent to dead letter queue are not consumable by listener. This flag is used
103-
* to turn on the consumable feature of dead letter queue.
91+
* By default, messages sent to dead letter queue are not consumable by listener. This flag is
92+
* used to turn on the consumable feature of dead letter queue. If this is set to true then
93+
* application should add message listener for the dead letter queue.
10494
*
10595
* @return true/false
10696
*/
@@ -128,7 +118,7 @@
128118
* listeners, that will violate exactly once processing. On the other hand if provided time is too
129119
* high then the message would be hidden from other consumers for a longer period.
130120
*
131-
* <p><b>NOTE:</b> This time is in milli seconds
121+
* <p><b>NOTE:</b> This time is in milliseconds
132122
*
133123
* @return visibilityTimeout visibility timeout
134124
*/

rqueue-core/src/main/java/com/github/sonus21/rqueue/common/RqueueRedisTemplate.java

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public Set<TypedTuple<V>> zrangeWithScore(String key, long start, long end) {
129129
return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
130130
}
131131

132+
public void zremRangeByScore(String key, long min, long max) {
133+
redisTemplate.opsForZSet().removeRangeByScore(key, min, max);
134+
}
135+
132136
public Set<V> getMembers(String key) {
133137
return redisTemplate.opsForSet().members(key);
134138
}

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

+59-21
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
@Configuration
4444
public class RqueueConfig {
4545

46+
private static final String brokerId = UUID.randomUUID().toString();
47+
private static final AtomicLong counter = new AtomicLong(1);
4648
private final RedisConnectionFactory connectionFactory;
4749
private final ReactiveRedisConnectionFactory reactiveRedisConnectionFactory;
4850
private final boolean sharedConnection;
4951
private final int dbVersion;
50-
private static final String brokerId = UUID.randomUUID().toString();
51-
private static final AtomicLong counter = new AtomicLong(1);
5252

5353
@Value("${rqueue.reactive.enabled:false}")
5454
private boolean reactiveEnabled;
@@ -83,11 +83,14 @@ public class RqueueConfig {
8383
@Value("${rqueue.simple.queue.prefix:}")
8484
private String simpleQueuePrefix;
8585

86-
@Value("${rqueue.delayed.queue.prefix:}")
87-
private String delayedQueuePrefix;
86+
@Value("${rqueue.scheduled.queue.prefix:}")
87+
private String scheduledQueuePrefix;
8888

89-
@Value("${rqueue.delayed.queue.channel.prefix:}")
90-
private String delayedQueueChannelPrefix;
89+
@Value("${rqueue.completed.queue.prefix:}")
90+
private String completedQueuePrefix;
91+
92+
@Value("${rqueue.scheduled.queue.channel.prefix:}")
93+
private String scheduledQueueChannelPrefix;
9194

9295
@Value("${rqueue.processing.queue.name.prefix:}")
9396
private String processingQueuePrefix;
@@ -139,6 +142,21 @@ public class RqueueConfig {
139142
@Value("${rqueue.internal.communication.channel.name.prefix:i-channel}")
140143
private String internalChannelNamePrefix;
141144

145+
@Value("${rqueue.completed.job.cleanup.interval:30000}")
146+
private long completedJobCleanupIntervalInMs;
147+
148+
public static String getBrokerId() {
149+
return brokerId;
150+
}
151+
152+
public boolean messageInTerminalStateShouldBeStored() {
153+
return getMessageDurabilityInTerminalStateInSecond() > 0;
154+
}
155+
156+
public long messageDurabilityInTerminalStateInMillisecond() {
157+
return getMessageDurabilityInTerminalStateInSecond() * Constants.ONE_MILLI;
158+
}
159+
142160
public String getInternalCommChannelName() {
143161
return prefix + internalChannelNamePrefix;
144162
}
@@ -157,19 +175,26 @@ private String getSimpleQueueSuffix() {
157175
return "queue-v2::";
158176
}
159177

160-
private String getDelayedQueueSuffix() {
161-
if (!StringUtils.isEmpty(delayedQueuePrefix)) {
162-
return delayedQueuePrefix;
178+
private String getScheduledQueueSuffix() {
179+
if (!StringUtils.isEmpty(scheduledQueuePrefix)) {
180+
return scheduledQueuePrefix;
163181
}
164182
if (dbVersion == 2) {
165183
return "d-queue::";
166184
}
167185
return "d-queue-v2::";
168186
}
169187

170-
private String getDelayedQueueChannelSuffix() {
171-
if (!StringUtils.isEmpty(delayedQueueChannelPrefix)) {
172-
return delayedQueueChannelPrefix;
188+
private String getCompletedQueueSuffix() {
189+
if (!StringUtils.isEmpty(completedQueuePrefix)) {
190+
return completedQueuePrefix;
191+
}
192+
return "c-queue::";
193+
}
194+
195+
private String getScheduledQueueChannelSuffix() {
196+
if (!StringUtils.isEmpty(scheduledQueueChannelPrefix)) {
197+
return scheduledQueueChannelPrefix;
173198
}
174199
if (dbVersion == 2) {
175200
return "d-channel::";
@@ -204,18 +229,22 @@ public String getQueueName(String queueName) {
204229
return prefix + getSimpleQueueSuffix() + getTaggedName(queueName);
205230
}
206231

207-
public String getDelayedQueueName(String queueName) {
232+
public String getCompletedQueueName(String queueName) {
233+
return prefix + getCompletedQueueSuffix() + getTaggedName(queueName);
234+
}
235+
236+
public String getScheduledQueueName(String queueName) {
208237
if (dbVersion == 1) {
209238
return "rqueue-delay::" + queueName;
210239
}
211-
return prefix + getDelayedQueueSuffix() + getTaggedName(queueName);
240+
return prefix + getScheduledQueueSuffix() + getTaggedName(queueName);
212241
}
213242

214-
public String getDelayedQueueChannelName(String queueName) {
243+
public String getScheduledQueueChannelName(String queueName) {
215244
if (dbVersion == 1) {
216245
return "rqueue-channel::" + queueName;
217246
}
218-
return prefix + getDelayedQueueChannelSuffix() + getTaggedName(queueName);
247+
return prefix + getScheduledQueueChannelSuffix() + getTaggedName(queueName);
219248
}
220249

221250
public String getProcessingQueueName(String queueName) {
@@ -248,6 +277,18 @@ private String getTaggedName(String queueName) {
248277
if (!clusterMode) {
249278
return queueName;
250279
}
280+
boolean left = false;
281+
boolean right = false;
282+
for (Character c : queueName.toCharArray()) {
283+
if (c == '{') {
284+
left = true;
285+
} else if (c == '}') {
286+
right = true;
287+
}
288+
}
289+
if (left && right) {
290+
return queueName;
291+
}
251292
return "{" + queueName + "}";
252293
}
253294

@@ -259,22 +300,19 @@ public String getJobsKey(String messageId) {
259300
return prefix + jobsCollectionNamePrefix + messageId;
260301
}
261302

262-
public String getDelDataName() {
303+
public String getDelDataName(String queueName) {
263304
return prefix
264305
+ delPrefix
265306
+ brokerId
266307
+ Constants.REDIS_KEY_SEPARATOR
308+
+ getTaggedName(queueName)
267309
+ counter.incrementAndGet();
268310
}
269311

270312
public Duration getJobDurabilityInTerminalState() {
271313
return Duration.ofSeconds(jobDurabilityInTerminalStateInSecond);
272314
}
273315

274-
public static String getBrokerId() {
275-
return brokerId;
276-
}
277-
278316
public String getLibVersion() {
279317
if (StringUtils.isEmpty(version)) {
280318
ClassPathResource resource =

0 commit comments

Comments
 (0)