简体   繁体   中英

Reconnection to Redis after reboot

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?

"

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?

sorry for my english, I would like to ask you a question: I have a springboot java project running + a library that connects me to a redis Sentinel, so far so good. I made two enpoints, the first one pushes to Redis with opsForStream().add(record)) , the other one reads where I'm inserting. This all works great, but when I restart the Sprinboot project everything in the stream on the redis side is lost....I can't read it...any suggestions? total thanks

"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM