https://github.com/abhirockzz/redis-cdi-example
Example for a Java EE CDI producer for Jedis (Redis Java client)
https://github.com/abhirockzz/redis-cdi-example
cdi dependency-injection docker docker-compose javaee7 jedis redis
Last synced: about 1 year ago
JSON representation
Example for a Java EE CDI producer for Jedis (Redis Java client)
- Host: GitHub
- URL: https://github.com/abhirockzz/redis-cdi-example
- Owner: abhirockzz
- License: mit
- Created: 2017-04-14T18:17:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-12T15:50:26.000Z (about 9 years ago)
- Last Synced: 2025-03-24T00:24:47.455Z (about 1 year ago)
- Topics: cdi, dependency-injection, docker, docker-compose, javaee7, jedis, redis
- Language: Java
- Homepage: https://abhirockzz.wordpress.com/2017/04/14/redis-cdi-example
- Size: 11.7 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Start with Docker Compose
- `git clone https://github.com/abhirockzz/redis-cdi-example.git`
- `mvn clean install` - creates `redis-cdi.war` in `target` dir
- `docker-compose up --build` - starts Redis and TomEE containers (you can switch to any other [Java EE runtime](https://github.com/abhirockzz/redis-cdi-example/blob/master/Dockerfile#L1))
## Test
- `docker-machine ip` - get the IP address of your Docker host. Let's call it `APP_HOST`
- `curl -X POST http://:8080/redis-cdi/kv/hello -d world` - this uses the [injected `Jedis` from the pool](https://github.com/abhirockzz/redis-cdi-example/blob/master/src/main/java/com/wordpress/abhirockzz/redis/cdi/PooledJedisProducer.java) to insert a key-value pair in Redis
- `curl -X GET http://:8080/redis-cdi/kv/hello` - this uses the [simple `Jedis` connection](https://github.com/abhirockzz/redis-cdi-example/blob/master/src/main/java/com/wordpress/abhirockzz/redis/cdi/JedisProducer.java) to fetch the value from Redis. You should get `world` in response (`HTTP 200`)
- `docker-compose down -v` once you're done....