Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateful redis cluster pubsub is not working #2850

Open
jigneshmpatel opened this issue May 10, 2024 · 1 comment
Open

Stateful redis cluster pubsub is not working #2850

jigneshmpatel opened this issue May 10, 2024 · 1 comment

Comments

@jigneshmpatel
Copy link

Bug Report

Current Behavior

The pub-sub for the cluster is not working and complaint about the encoder, method. I have tested this with the following versions of netty
<io.netty.version>4.1.109.Final</io.netty.version>
<io.netty.version>4.1.59.Final</io.netty.version>

Stack trace
java.lang.NoSuchMethodError: io.netty.util.CharsetUtil.encoder(Ljava/nio/charset/Charset;)Ljava/nio/charset/CharsetEncoder;

Input Code

Input Code
    public void publishToEncounterCheckoutTimeChannel(CacheConstants cacheConstants, String key, String checkoutTimeInSeconds)  {

        String redisKey = this.getDelimiter().add(cacheConstants.getCacheName()).add(key).toString();
        StatefulRedisClusterPubSubConnection<String, String> connection=  connectToRedisCluster.getClusterPubSubConnection();
        RedisClusterPubSubCommands commands = connection.sync();
        commands.publish("EncounterCheckoutTimeChannel",redisKey );
        // The may be in seconds
        commands.expire(redisKey ,Long.parseLong(checkoutTimeInSeconds));

    }
        public StatefulRedisClusterPubSubConnection<String, String> getClusterPubSubConnection() {
        clusterClient = this.establishConnection();

        return clusterClient.connectPubSub();
    }
//following works as I am using same setup with regular(NON Pubsub) setups
  private RedisClusterClient  establishConnection() {
        String profileName = configProperties.getProperty("buildProfile");
        logger.info("Profile Name :- {}", profileName);
        char authpswdcharArray[] = configProperties.getProperty("authPassword").toCharArray();
        logger.debug("authPasswordArray:"+authpswdcharArray.toString());
        logger.debug("ClusterHost :- {}", configProperties.getProperty("ECclusterhost"));
        boolean sslFlag = true;
        if(profileName.equalsIgnoreCase("standalone")){
            sslFlag = false;
        }
        RedisURI redisURI = RedisURI.Builder.redis(configProperties.getProperty("ECclusterhost"),
                Integer.parseInt(configProperties.getProperty("ECclusterport"))).withPassword(authpswdcharArray).withSsl(sslFlag).build();
        clusterClient = RedisClusterClient.create(redisURI);
        logger.debug("clusterClient got created :- {}", clusterClient);
        return clusterClient;

    }

Expected behavior/code

Environment

  • Lettuce version(s): [ 6.0.2.RELEASE]
  • Redis version: checking against AWS, not sure about the appropriate version.

Possible Solution

There should not be an error for the encoder method as I believe I am using the appropriate version of netty.
StatefulRedisClusterPubSubConnection should work.

Additional context

@jigneshmpatel
Copy link
Author

jigneshmpatel commented May 13, 2024

Initially, I used to have a following dependencies defined in pom.xml

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-common</artifactId>
            <version>${io.netty.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
            <version>${io.netty.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
            <version>${io.netty.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-resolver-dns</artifactId>
            <version>${io.netty.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-dns</artifactId>
            <version>${io.netty.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-resolver</artifactId>
            <version>${io.netty.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
            <version>${io.netty.version}</version>
            <scope>runtime</scope>
        </dependency>

but replacing it with the following worked.

<dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>${io.netty.version}</version>
            <scope>compile</scope>
        </dependency>

I didn't like to import all, so if there is a better solution please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant