Redis CDI example….

Here is an example of a CDI producer for Redis using the Jedis (Java) client for Redis. Check out the project README to get this up and running…. Below is a quick summary

Use of CDI Qualifier

Two types of CDI producers have been demonstrated

  1. non-qualified: no additional qualifiers for simply obtaining a standalone Jedis connection
  2. qualified: uses a custom CDI Qualifier (@FromJedisPool) to get the connection from the Jedis pool


  1. @RequestScoped for pooled producer: the Jedis connection is returned to the pool after the method invocation is complete
  2. @DependentScoped for basic producer: the lifetime of the Jedis connection object depends on which component has injected it

Common stuff

  1. In both the cases, the producer (CDI) bean itself is @ApplicationScoped and the producers have been scoped differently
  2. An equivalent @Disposes method has been provided to perform clean up (i.e. close the connection or return it to the pool)

Further reading



About Abhishek

Java EE & distributed systems junkie who frequently blogs at as well as Oh, I have also authored a few (mini) books, articles, Refcards etc. :-)
This entry was posted in Java EE, NoSQL and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s