Skip to content

Commit 6707749

Browse files
committed
fix: prioerity queue issue
1 parent f54fb32 commit 6707749

9 files changed

Lines changed: 466 additions & 47 deletions

File tree

README.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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-Backed Job Queue and Scheduler for Spring and Spring Boot</h1>
3+
<h1 style="float:left">Rqueue: Job Queue and Scheduler for Spring and Spring Boot (Redis &amp; NATS)</h1>
44
</div>
55

66
[![Coverage Status](https://coveralls.io/repos/github/sonus21/rqueue/badge.svg?branch=master)](https://coveralls.io/github/sonus21/rqueue?branch=master)
77
[![Maven Central](https://img.shields.io/maven-central/v/com.github.sonus21/rqueue-core)](https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core)
88
[![Javadoc](https://javadoc.io/badge2/com.github.sonus21/rqueue-core/javadoc.svg)](https://javadoc.io/doc/com.github.sonus21/rqueue-core)
99
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
1010

11-
**Rqueue** is a Redis-backed job queue and producer-consumer system for Spring and Spring Boot. It
12-
supports both producers and consumers for background jobs, scheduled tasks, and event-driven
13-
workflows, similar to Sidekiq or Celery, but fully integrated into the Spring programming model with
14-
annotation-driven APIs and minimal setup.
11+
**Rqueue** is a job queue and producer-consumer system for Spring and Spring Boot with pluggable
12+
broker backends — **Redis** (default) and **NATS JetStream**. It supports producers and consumers
13+
for background jobs, scheduled tasks, and event-driven workflows, similar to Sidekiq or Celery,
14+
fully integrated into the Spring programming model with annotation-driven APIs and minimal setup.
1515

1616
<br/>
1717

@@ -49,19 +49,21 @@ annotation-driven APIs and minimal setup.
4949
* Monitor in-flight, queued, and scheduled messages with metrics
5050
* Use the built-in web dashboard for queue visibility and latency insights
5151

52-
* **Redis and platform support**
52+
* **Backend and platform support**
53+
* Switch backends with a single property (`rqueue.backend=redis|nats`)
5354
* Use a separate Redis setup for Rqueue if needed
5455
* Support Redis standalone, Sentinel, and Cluster setups
5556
* Work with Lettuce for Redis Cluster
5657
* Support reactive Redis and Spring WebFlux
58+
* Use NATS JetStream as a drop-in Redis replacement (add `rqueue-nats` and set `rqueue.backend=nats`)
5759

5860
### Requirements
5961

6062
* Spring 5+, 6+, 7+
61-
* Java 1.8+,17, 21
62-
* Spring boot 2+,3+,4+
63-
* Lettuce client for Redis cluster
64-
* Read master preference for Redis cluster
63+
* Java 1.8+, 17, 21
64+
* Spring Boot 2+, 3+, 4+
65+
* **Redis backend (default):** Lettuce client; read-master preference for Redis Cluster
66+
* **NATS backend:** NATS Server 2.2+ with JetStream enabled (`nats-server -js`); `rqueue-nats` on the classpath
6567

6668
## Getting Started
6769

@@ -95,6 +97,40 @@ from [Maven central](https://search.maven.org/search?q=g:com.github.sonus21%20AN
9597
9698
No additional configurations are required, only dependency is required.
9799
100+
##### Spring Boot with NATS backend
101+
102+
To use NATS JetStream instead of Redis, add `rqueue-nats` alongside the starter and set
103+
`rqueue.backend=nats` in `application.properties`:
104+
105+
* Gradle
106+
```groovy
107+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:4.0.0-RELEASE'
108+
implementation 'com.github.sonus21:rqueue-nats:4.0.0-RELEASE'
109+
```
110+
* Maven
111+
```xml
112+
<dependency>
113+
<groupId>com.github.sonus21</groupId>
114+
<artifactId>rqueue-spring-boot-starter</artifactId>
115+
<version>4.0.0-RELEASE</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>com.github.sonus21</groupId>
119+
<artifactId>rqueue-nats</artifactId>
120+
<version>4.0.0-RELEASE</version>
121+
</dependency>
122+
```
123+
124+
Then in `application.properties`:
125+
```properties
126+
rqueue.backend=nats
127+
rqueue.nats.connection.url=nats://localhost:4222
128+
```
129+
130+
No `RedisConnectionFactory` bean is required. Start a JetStream-enabled NATS server with
131+
`nats-server -js` and the application is ready. See the [NATS backend](#nats-backend) section
132+
below for streams, KV buckets, and advanced configuration.
133+
98134
---
99135

100136
#### Spring Framework

docs/index.md

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
layout: default
33
title: Home
44
nav_order: 1
5-
description: Rqueue Redis Based Async Message Processor
5+
description: Rqueue Job Queue and Scheduler for Spring — Redis and NATS JetStream backends
66
permalink: /
77
---
88

9-
# Rqueue | Redis-Backed Job Queue and Scheduler For Spring Framework
9+
# Rqueue | Job Queue and Scheduler For Spring Framework (Redis &amp; NATS)
1010

1111
{: .fs-4 }
1212

13-
Rqueue is a Redis-backed job queue and producer-consumer system for Spring and Spring Boot. It
14-
supports both producers and consumers for background jobs, scheduled tasks, and event-driven
15-
workflows, similar to Sidekiq or Celery, while staying fully integrated with the Spring programming
16-
model through annotation-driven APIs and minimal setup.
13+
Rqueue is a job queue and producer-consumer system for Spring and Spring Boot with pluggable
14+
broker backends — **Redis** (default) and **NATS JetStream**. It supports producers and consumers
15+
for background jobs, scheduled tasks, and event-driven workflows, similar to Sidekiq or Celery,
16+
while staying fully integrated with the Spring programming model through annotation-driven APIs
17+
and minimal setup.
1718

1819
{: .fs-6 .fw-300 }
1920

@@ -55,19 +56,21 @@ model through annotation-driven APIs and minimal setup.
5556
* Use the built-in web dashboard for queue visibility, worker activity, and message operations
5657
* Override message ID generation with a custom `RqueueMessageIdGenerator` bean
5758

58-
* **Redis and platform support**
59+
* **Backend and platform support**
60+
* Switch backends with a single property (`rqueue.backend=redis|nats`)
5961
* Support Redis standalone, Sentinel, and Cluster setups
6062
* Support reactive Redis and Spring WebFlux
6163
* Keep Redis configuration flexible for different deployment models
64+
* Use NATS JetStream as a drop-in Redis replacement (add `rqueue-nats` and set `rqueue.backend=nats`)
6265

6366
### Requirements
6467

6568
* Spring 6+, 7+
6669
* Spring Boot 3+, 4+
6770
* Java 21+
6871
* Spring Reactive
69-
* Lettuce client for Redis cluster
70-
* Read master preference for Redis cluster
72+
* **Redis backend (default):** Lettuce client; read-master preference for Redis Cluster
73+
* **NATS backend:** NATS Server 2.2+ with JetStream enabled (`nats-server -js`); `rqueue-nats` on the classpath
7174

7275
## Getting Started
7376

@@ -80,7 +83,8 @@ inconsistencies. Queues should **only** be created when using Rqueue as a produc
8083
{: .highlight }
8184
The Rqueue GitHub repository includes several sample applications for local testing and demonstration:
8285

83-
* [Rqueue Spring Boot Example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-boot-example)
86+
* [Rqueue Spring Boot Example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-boot-example) — Redis backend
87+
* [Rqueue Spring Boot NATS Example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-boot-nats-example) — NATS JetStream backend
8488
* [Rqueue Spring Boot Reactive Example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-boot-reactive-example)
8589
* [Rqueue Spring Example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-example)
8690

@@ -161,6 +165,69 @@ public class Application {
161165

162166
---
163167

168+
### NATS JetStream Backend
169+
170+
To use NATS JetStream instead of Redis, add `rqueue-nats` alongside the starter and set
171+
`rqueue.backend=nats`. No `RedisConnectionFactory` bean is required.
172+
173+
{: .warning }
174+
The NATS backend does not support delayed enqueue, scheduled messages, or cron jobs (`enqueueIn`,
175+
`enqueueAt`, `enqueuePeriodic`). These throw `UnsupportedOperationException`. Use the Redis
176+
backend for workloads that require scheduling.
177+
178+
#### Spring Boot 4.x — NATS Setup
179+
180+
* Gradle
181+
```groovy
182+
implementation 'com.github.sonus21:rqueue-spring-boot-starter:4.0.0-RELEASE'
183+
implementation 'com.github.sonus21:rqueue-nats:4.0.0-RELEASE'
184+
```
185+
186+
* Maven
187+
```xml
188+
<dependency>
189+
<groupId>com.github.sonus21</groupId>
190+
<artifactId>rqueue-spring-boot-starter</artifactId>
191+
<version>4.0.0-RELEASE</version>
192+
</dependency>
193+
<dependency>
194+
<groupId>com.github.sonus21</groupId>
195+
<artifactId>rqueue-nats</artifactId>
196+
<version>4.0.0-RELEASE</version>
197+
</dependency>
198+
```
199+
200+
Then in `application.properties`:
201+
202+
```properties
203+
rqueue.backend=nats
204+
rqueue.nats.connection.url=nats://localhost:4222
205+
```
206+
207+
Start a JetStream-enabled NATS server:
208+
209+
```sh
210+
# native binary
211+
nats-server -js
212+
213+
# Docker
214+
docker run -p 4222:4222 nats:latest -js
215+
```
216+
217+
Rqueue provisions streams and KV buckets at startup. For locked-down JetStream accounts where the
218+
application credentials cannot call `add_stream` / `kv_create` at runtime, set:
219+
220+
```properties
221+
rqueue.nats.auto-create-streams=false
222+
rqueue.nats.auto-create-kv-buckets=false
223+
```
224+
225+
…and pre-create the streams and buckets before starting the application. See the
226+
[rqueue-spring-boot-nats-example](https://github.com/sonus21/rqueue/tree/master/rqueue-spring-boot-nats-example)
227+
for a complete working example and the repository README for the full stream / KV bucket reference.
228+
229+
---
230+
164231
{: .highlight }
165232

166233
Once Rqueue is configured, you can use its methods and annotations consistently

0 commit comments

Comments
 (0)