feat(java): add support for remaining pubsub commands #5114
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add PubSub Subscription Commands to Java Client
This PR resolves this issue
Summary
This PR adds support for 6 PubSub subscription commands to the Java client, enabling runtime subscription management for both standalone and cluster modes with full binary-safe support.
Commands Implemented
Base Commands (Standalone + Cluster)
Cluster-Only Commands
Motivation
These commands provide runtime subscription management capabilities that complement the existing configuration-time subscription setup. This enables:
Changes Made
1. Interface Definitions
PubSubBaseCommands.java- Added 8 method signatures:PubSubClusterCommands.java- Added 4 cluster-specific method signatures:2. Client Implementations
GlideClient.java- Implemented 8 methods (4 base commands × 2 variants each)CompletableFuture<Void>GlideClusterClient.java- Implemented 12 methods (8 base + 4 cluster-specific)3. Integration Tests
PubSubTests.java- Added 8 comprehensive tests:test_pubsub_subscribe_runtime- Runtime SUBSCRIBE (standalone + cluster)test_pubsub_unsubscribe_runtime- Runtime UNSUBSCRIBE (standalone + cluster)test_pubsub_unsubscribe_all- UNSUBSCRIBE without arguments (standalone + cluster)test_pubsub_psubscribe_runtime- Runtime PSUBSCRIBE (standalone + cluster)test_pubsub_punsubscribe_runtime- Runtime PUNSUBSCRIBE (standalone + cluster)test_pubsub_punsubscribe_all- PUNSUBSCRIBE without arguments (standalone + cluster)test_pubsub_ssubscribe_runtime- Runtime SSUBSCRIBE (cluster only, Valkey 7.0+)test_pubsub_sunsubscribe_runtime- Runtime SUNSUBSCRIBE (cluster only, Valkey 7.0+)All tests include proper cleanup to prevent interference between tests.
4. Documentation
CHANGELOG.mdwith new commandsAPI Design
Async-First Pattern
All commands return
CompletableFuture<Void>following GLIDE's async-first design:Binary-Safe Support
Each command has both String[] and GlideString[] variants:
Unsubscribe All Pattern
Empty array unsubscribes from all channels/patterns:
Testing
Test Coverage
:integTest:pubsubTestRunning Tests
cd java ./gradlew :integTest:pubsubTest -x spotlessJava -x spotlessJavaCheckTest Results
Compatibility
Client Compatibility
Engine Compatibility
Example Usage
Standalone Mode
Cluster Mode with Sharded PubSub
Breaking Changes
None - This is a purely additive change.
Checklist
Additional Notes