redisjbosswildflydatasourcejedis

Adding jedis module to be used as datasource in wildfly 11


I am trying to install jedis module in wildfly-11 so that I can create a datasource. I am using jedis-5.1.0.jar for this purpose.

  1. I have created the directory org/redis/jdbc/main in $JBOSS_HOME/modules/system/layers/base and copied my jedis jar in it.

  2. I have also created a module.xml in this directory with the following content.

    <?xml version="1.0" encoding="UTF-8"?>    
    <module xmlns="urn:jboss:module:1.5" name="org.redis.jdbc">    
        <resources>    
            <resource-root path="jedis-5.1.0.jar"/>    
        </resources>    
        <dependencies>    
            <module name="org.apache.commons.pool2"/>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
        </dependencies>    
    </module>
    
  3. For the connection pool I am using commons-pool2-2.12.0.jar. As before I have created org/apache/commons/pool2/main and added the following in the module.xml

     <module xmlns="urn:jboss:module:1.5" name="org.apache.commons.pool2">    
         <properties>    
             <property name="jboss.api" value="private"/>    
         </properties>    
         <resources>    
             <resource-root path="commons-pool2-2.12.0.jar"/>    
         </resources>    
         <dependencies>    
         </dependencies>    
     </module>    
    

As I run jboss-cli.sh with --command="/core-service=module-loading:list-resource-loader-paths(module=org.redis.jdbc) I can see that the module is properly loaded.

Now coming to the datasource in standalone-ha.xml. I have done the following

             <datasource jta="true" jndi-name="java:jboss/datasources/REDISDS" pool-name="redisds" enabled="true" use-java-context="true">    
                <connection-url>jdbc:redis://REDIS_IP:6379</connection-url>    
                <driver>redis</driver>    
                <pool>    
                    <min-pool-size>5</min-pool-size>    
                    <max-pool-size>20</max-pool-size>    
                    <prefill>true</prefill>    
                </pool>    
                <security>    
                    <user-name>SAME_AS_PASSWORD</user-name>    
                    <password>PASSWORD</password>    
                </security>    
                <validation>    
                    <background-validation>true</background-validation>    
                    <background-validation-millis>60000</background-validation-millis>    
                    <validate-on-match>true</validate-on-match>    
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>    
                </validation>    
            </datasource>

I have also defined the driver

<driver name="redis" module="org.redis.jdbc">
    <!-- <driver-class>redis.clients.jedis.JedisConnectionFactory</driver-class> -->
    <!-- <xa-datasource-class>redis.clients.jedis.RedisDataSource</xa-datasource-class> -->
</driver>

None of the driver class exist in jedis-5.1.0.jar so I have commented it.

Now when I start the wildfly server I get the following error

09:24:18,575 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "redisds")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.redis"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "org.wildfly.data-source.redisds is missing [jboss.jdbc-driver.redis]",
    "jboss.driver-demander.java:jboss/datasources/REDISDS is missing [jboss.jdbc-driver.redis]"
]
}
09:24:18,577 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "redisds")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
    "jboss.jdbc-driver.redis",
    "jboss.jdbc-driver.redis"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "org.wildfly.data-source.redisds is missing [jboss.jdbc-driver.redis]",
    "jboss.driver-demander.java:jboss/datasources/REDISDS is missing [jboss.jdbc-driver.redis]",
    "org.wildfly.data-source.redisds is missing [jboss.jdbc-driver.redis]"
]
}

I have suspision that I am not using a compatible redis jdbc driver. Searching internet did not offer much help. Can someone kindly point out the mistake?

Thank you.

EDIT following this link , I have managed to create a datasource using the cdata jdbc driver, but that requires licensing. My suspision only grows, that the jedis jar I am using is not jdbc compliant.


Solution

  • Ok I have figured it out. My suspision was correct. Jedis is not JDBC compliant. I found this github repo. I cloned it and ran the command mvn package. It generated two jars redis-jdbc-driver-0.0.2.jar and redis-jdbc-driver-core-0.0.2.jar. I then added the jars as module in my wildfly as followed

    1. module add --name=org.jdbc.jedis.core --resources=redis-jdbc-driver-core-0.0.2.jar
    2. module add --name=org.jdbc.jedis.all --resources=redis-jdbc-driver-0.0.2-all.jar --dependencies=org.jdbc.jedis.core
    

    Now one can test the connection as followed

    ./jboss-cli.sh --connect --controller=JBOSS_IP:9990 --command="/subsystem=datasources/data-source=XXX:test-connection-in-pool"
    

    Here XXX is your datasource pool-name. It now gives the output

    {
        "outcome" => "success",
        "result" => [true]
    }
    

    NOTE : the driver-class is com.itmuch.redis.jdbc.redis.RedisDriver in driver configuration.