Question

I've a bunch long running processes that connect to a Redis server (using Jedis). Everything works fine as long as I don't reboot the machine running Redis or restart the Redis server. As soon as I reboot or restart the connection is lost. Is there a standard way of dealing with this use case in Redis/Jedis or do I need to put this logic in all my clients myself?

Was it helpful?

Solution

Redis Failure/Connection Dropped
In this case, redis either goes down or drops the connection while your process remains active. To ensure the process gets a good connection, use testOnBorrow=true in jedis connection/pool config. Jedis will test each connection with 'PING' before using it; if redis does not respond, the connection is discarded and it will try another connection.

Machine Reboot/Restart (not redis)
If the application node fails or reboots, your "processes" should be configured to restart automatically upon reboot (if that's the behavior you desire), or someone starts it manually. In either case, I'd expect your process to create and initialize a new jedis connection before it does any real work...so what else do you need beyond that?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top