22layout : default
33title : Home
44nav_order : 1
5- description : Rqueue Redis Based Async Message Processor
5+ description : Rqueue Job Queue and Scheduler for Spring — Redis and NATS JetStream backends
66permalink : /
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 }
8184The 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
166233Once Rqueue is configured, you can use its methods and annotations consistently
0 commit comments