diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml index b8f76c09c4..e4c5eb4002 100644 --- a/persistence-modules/redis/pom.xml +++ b/persistence-modules/redis/pom.xml @@ -33,7 +33,7 @@ redis.clients jedis - ${redisson.version} + ${jedis.version} com.github.kstyrc @@ -48,12 +48,19 @@ io.lettuce lettuce-core - + + + io.netty + netty-transport-native-epoll + ${epoll.version} + 0.6 - 3.3.0 + 3.13.1 + 3.3.0 + 4.1.50.Final diff --git a/persistence-modules/redis/src/main/java/com/baeldung/CustomMessage.java b/persistence-modules/redis/src/main/java/com/baeldung/CustomMessage.java index 1d6a7e4e13..26ebe46f64 100644 --- a/persistence-modules/redis/src/main/java/com/baeldung/CustomMessage.java +++ b/persistence-modules/redis/src/main/java/com/baeldung/CustomMessage.java @@ -1,9 +1,11 @@ package com.baeldung; +import java.io.Serializable; + /** * Created by johnson on 3/9/17. */ -public class CustomMessage { +public class CustomMessage implements Serializable { private String message; public CustomMessage() { diff --git a/persistence-modules/redis/src/main/java/com/baeldung/Ledger.java b/persistence-modules/redis/src/main/java/com/baeldung/Ledger.java index da72791f7e..c9fb81979e 100644 --- a/persistence-modules/redis/src/main/java/com/baeldung/Ledger.java +++ b/persistence-modules/redis/src/main/java/com/baeldung/Ledger.java @@ -1,6 +1,8 @@ package com.baeldung; -public class Ledger { +import java.io.Serializable; + +public class Ledger implements Serializable { public Ledger() { } diff --git a/persistence-modules/redis/src/main/resources/singleNodeConfig.json b/persistence-modules/redis/src/main/resources/singleNodeConfig.json index f56e13dcfc..c46a542b46 100644 --- a/persistence-modules/redis/src/main/resources/singleNodeConfig.json +++ b/persistence-modules/redis/src/main/resources/singleNodeConfig.json @@ -1,13 +1,10 @@ { "singleServerConfig": { "idleConnectionTimeout": 10000, - "pingTimeout": 1000, "connectTimeout": 10000, "timeout": 3000, "retryAttempts": 3, "retryInterval": 1500, - "reconnectionTimeout": 3000, - "failedAttempts": 3, "password": null, "subscriptionsPerConnection": 5, "clientName": null, @@ -17,11 +14,9 @@ "connectionMinimumIdleSize": 10, "connectionPoolSize": 64, "database": 0, - "dnsMonitoring": false, "dnsMonitoringInterval": 5000 }, "threads": 0, "nettyThreads": 0, - "codec": null, - "useLinuxNativeEpoll": false + "codec": null } \ No newline at end of file diff --git a/persistence-modules/redis/src/main/resources/singleNodeConfig.yaml b/persistence-modules/redis/src/main/resources/singleNodeConfig.yaml index 1b05c46be2..9074434bd1 100644 --- a/persistence-modules/redis/src/main/resources/singleNodeConfig.yaml +++ b/persistence-modules/redis/src/main/resources/singleNodeConfig.yaml @@ -1,12 +1,9 @@ singleServerConfig: idleConnectionTimeout: 10000 - pingTimeout: 1000 connectTimeout: 10000 timeout: 3000 retryAttempts: 3 retryInterval: 1500 - reconnectionTimeout: 3000 - failedAttempts: 3 password: null subscriptionsPerConnection: 5 clientName: null @@ -16,9 +13,7 @@ singleServerConfig: connectionMinimumIdleSize: 10 connectionPoolSize: 64 database: 0 - dnsMonitoring: false dnsMonitoringInterval: 5000 threads: 0 nettyThreads: 0 -codec: ! {} -useLinuxNativeEpoll: false \ No newline at end of file +codec: ! {} \ No newline at end of file diff --git a/persistence-modules/redis/src/test/java/com/baeldung/RedissonConfigurationIntegrationTest.java b/persistence-modules/redis/src/test/java/com/baeldung/RedissonConfigurationIntegrationTest.java index 66f61ae5dd..c2e771d7b8 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/RedissonConfigurationIntegrationTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/RedissonConfigurationIntegrationTest.java @@ -48,7 +48,7 @@ public class RedissonConfigurationIntegrationTest { public void givenJavaConfig_thenRedissonConnectToRedis() { Config config = new Config(); config.useSingleServer() - .setAddress(String.format("127.0.0.1:%s", port)); + .setAddress(String.format("redis://127.0.0.1:%s", port)); client = Redisson.create(config); diff --git a/persistence-modules/redis/src/test/java/com/baeldung/RedissonIntegrationTest.java b/persistence-modules/redis/src/test/java/com/baeldung/RedissonIntegrationTest.java index 53d77c2699..8c8e6a02dd 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/RedissonIntegrationTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/RedissonIntegrationTest.java @@ -7,6 +7,7 @@ import org.redisson.Redisson; import org.redisson.RedissonMultiLock; import org.redisson.api.*; import org.redisson.client.RedisClient; +import org.redisson.client.RedisClientConfig; import org.redisson.client.RedisConnection; import org.redisson.client.codec.StringCodec; import org.redisson.client.protocol.RedisCommands; @@ -103,10 +104,10 @@ public class RedissonIntegrationTest { public void givenTopicSubscribedToAChannel_thenReceiveMessageFromChannel() throws ExecutionException, InterruptedException { CompletableFuture future = new CompletableFuture<>(); - RTopic subscribeTopic = client.getTopic("baeldung"); - subscribeTopic.addListener((channel, customMessage) -> future.complete(customMessage.getMessage())); + RTopic subscribeTopic = client.getTopic("baeldung"); + subscribeTopic.addListener(CustomMessage.class, (channel, customMessage) -> future.complete(customMessage.getMessage())); - RTopic publishTopic = client.getTopic("baeldung"); + RTopic publishTopic = client.getTopic("baeldung"); long clientsReceivedMessage = publishTopic.publish(new CustomMessage("This is a message")); @@ -203,10 +204,10 @@ public class RedissonIntegrationTest { batch.getMap("ledgerMap").fastPutAsync("1", "2"); batch.getMap("ledgerMap").putAsync("2", "5"); - List result = batch.execute(); + BatchResult batchResult = batch.execute(); RMap map = client.getMap("ledgerMap"); - assertTrue(result.size() > 0 && map.get("1").equals("2")); + assertTrue(batchResult.getResponses().size() > 0 && map.get("1").equals("2")); } @Test @@ -220,7 +221,9 @@ public class RedissonIntegrationTest { @Test public void givenLowLevelRedisCommands_thenExecuteLowLevelCommandsOnRedis(){ - RedisClient client = new RedisClient("localhost", 6379); + RedisClientConfig redisClientConfig = new RedisClientConfig(); + redisClientConfig.setAddress("localhost", 6379); + RedisClient client = RedisClient.create(redisClientConfig); RedisConnection conn = client.connect(); conn.sync(StringCodec.INSTANCE, RedisCommands.SET, "test", 0);