Handle disconnect at doStop
This commit is contained in:
parent
5a4b3cb38a
commit
f1c53077a4
@ -68,6 +68,7 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
|||||||
private final Config config;
|
private final Config config;
|
||||||
private final RedisClient client;
|
private final RedisClient client;
|
||||||
private RedisCommands<String, String> commands;
|
private RedisCommands<String, String> commands;
|
||||||
|
private StatefulRedisConnection<String, String> connection;
|
||||||
private final Timer redisGetRequestTimer;
|
private final Timer redisGetRequestTimer;
|
||||||
private final Meter redisGetRequestErrors;
|
private final Meter redisGetRequestErrors;
|
||||||
private final Timer redisSetRequestTimer;
|
private final Timer redisSetRequestTimer;
|
||||||
@ -102,14 +103,15 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
|||||||
// Add code to initialise Redis connection
|
// Add code to initialise Redis connection
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception {
|
protected void doStart() throws Exception {
|
||||||
StatefulRedisConnection<String, String> connection = this.client.connect();
|
connection = this.client.connect();
|
||||||
this.commands = connection.sync();
|
this.commands = connection.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add code to close Redis connection
|
// Add code to close Redis connection
|
||||||
@Override
|
@Override
|
||||||
protected void doStop() throws Exception {
|
protected void doStop() throws Exception {
|
||||||
|
connection.close();
|
||||||
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user