Skip to content

Commit 89922c4

Browse files
committed
Make Redis collaborators optional on RqueueBeanProvider and RqueueMetrics
Both classes used to mandate Redis-shaped beans through @Autowired defaults. With those beans now gated behind RedisBackendCondition the NATS backend path failed Spring DI: - RqueueBeanProvider.{rqueueMessageMetadataService, rqueueSystemConfigDao, rqueueJobDao, rqueueLockManager} switched to @Autowired(required=false). The bean provider already exposes setters and tolerates nulls in the Redis-only consumer paths. - RqueueMetrics.rqueueStringDao switched to @Autowired(required=false); the size() helper short-circuits to 0 when no Redis is wired so the micrometer gauges still register but report zero on NATS deployments. Assisted-By: Claude Code
1 parent a00faa2 commit 89922c4

7 files changed

Lines changed: 16 additions & 5 deletions

File tree

.claude/scheduled_tasks.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sessionId":"dc2dc485-0866-434b-8dc1-34030f338e1f","pid":58262,"procStart":"Thu Apr 30 14:08:59 2026","acquiredAt":1777558217212}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit fb3878bef95eb65f55d68c86565accc03218375d
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 434c42cbdd3455e3f6eab0b17483d97128b21d19
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 764bd5868feb27e80084cf298c4ce6cadd39af31
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 436395a92b893a6adc2ed94176b56489cdfe333b

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
@Setter
3636
public class RqueueBeanProvider {
3737

38-
@Autowired
38+
// Redis-only collaborators — absent on the NATS backend path; consumers must null-check.
39+
@Autowired(required = false)
3940
private RqueueMessageMetadataService rqueueMessageMetadataService;
4041

41-
@Autowired
42+
@Autowired(required = false)
4243
private RqueueSystemConfigDao rqueueSystemConfigDao;
4344

44-
@Autowired
45+
@Autowired(required = false)
4546
private RqueueJobDao rqueueJobDao;
4647

4748
@Autowired
@@ -50,7 +51,7 @@ public class RqueueBeanProvider {
5051
@Autowired
5152
private ApplicationEventPublisher applicationEventPublisher;
5253

53-
@Autowired
54+
@Autowired(required = false)
5455
private RqueueLockManager rqueueLockManager;
5556

5657
@Autowired(required = false)

rqueue-core/src/main/java/com/github/sonus21/rqueue/metrics/RqueueMetrics.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,19 @@ public class RqueueMetrics implements RqueueMetricsRegistry {
4848
@Autowired
4949
private MeterRegistry meterRegistry;
5050

51-
@Autowired
51+
// Redis-only — null when rqueue.backend=nats; size() returns 0 in that case.
52+
@Autowired(required = false)
5253
private RqueueStringDao rqueueStringDao;
5354

5455
public RqueueMetrics(QueueCounter queueCounter) {
5556
this.queueCounter = queueCounter;
5657
}
5758

5859
private long size(String name, boolean isZset) {
60+
if (rqueueStringDao == null) {
61+
// No Redis available (e.g. rqueue.backend=nats); these metrics are Redis-shaped.
62+
return 0;
63+
}
5964
Long val;
6065
if (!isZset) {
6166
val = rqueueStringDao.getListSize(name);

0 commit comments

Comments
 (0)