Skip to content

feat(jedis-compatibility): Add JedisPubSub callback support for dynamic subscriptions #5469

@prashanna-frsh

Description

@prashanna-frsh

Overview

Support Jedis-style JedisPubSub callback listeners in the compatibility layer to enable full PubSub functionality with message handling.

Background

PR #5286 adds basic PubSub commands (publish, pubsubChannels, pubsubNumSub, pubsubNumPat) to the Jedis compatibility layer. However, the subscribe/unsubscribe methods with JedisPubSub callbacks are not yet implemented.

Requested Feature

Implement JedisPubSub and BinaryJedisPubSub callback support to match the Jedis API:

JedisPubSub jedisPubSub = new JedisPubSub() {
    @Override
    public void onMessage(String channel, String message) {
        // Handle message
    }
    
    @Override
    public void onSubscribe(String channel, int subscribedChannels) {
        // Handle subscription
    }
    
    @Override
    public void onUnsubscribe(String channel, int subscribedChannels) {
        // Handle unsubscription
    }
};

jedis.subscribe(jedisPubSub, "channel1", "channel2");

Implementation Considerations

  • Map JedisPubSub callbacks to GLIDE's dynamic subscription APIs
  • Support both JedisPubSub (String) and BinaryJedisPubSub (byte[]) variants
  • Handle pattern subscriptions (psubscribe) and sharded subscriptions (ssubscribe)
  • Ensure thread-safety for callback execution
  • Consider blocking vs non-blocking subscription models

Related

Labels

Feature, java

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatibility 🧭Tasks & PRs for compatibility of GLIDE with other clients

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions