From 5a4943bd9d32b026433b6d652ef3ff56976f1069 Mon Sep 17 00:00:00 2001 From: Govindass Date: Mon, 2 Nov 2020 14:14:38 +0200 Subject: [PATCH] so I found that this threadpool was actually needed, oops due to it not having threadpool, froze my server at one point --- pom.xml | 2 +- .../net/limework/rediskript/managers/RedisManager.java | 4 +++- .../rediskript/skript/elements/EffSendMessage.java | 10 +++++----- src/main/resources/plugin.yml | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index ac944df..1bbb1e5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - net.limework.core + net.limework.rediskript RediSkript 1.2.2 jar diff --git a/src/main/java/net/limework/rediskript/managers/RedisManager.java b/src/main/java/net/limework/rediskript/managers/RedisManager.java index c3d3103..090f030 100644 --- a/src/main/java/net/limework/rediskript/managers/RedisManager.java +++ b/src/main/java/net/limework/rediskript/managers/RedisManager.java @@ -52,7 +52,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable { config.getInt("Redis.TimeOut"), config.getString("Redis.Password"), config.getBoolean("Redis.useTLS")); - RedisService = Executors.newSingleThreadExecutor(); + RedisService = Executors.newFixedThreadPool(3); try { this.subscribeJedis = this.jedisPool.getResource(); } catch (Exception ignored) { @@ -163,4 +163,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable { public Encryption getEncryption() { return encryption; } + + public ExecutorService getRedisService() { return RedisService; } } diff --git a/src/main/java/net/limework/rediskript/skript/elements/EffSendMessage.java b/src/main/java/net/limework/rediskript/skript/elements/EffSendMessage.java index 42a6eaf..427d704 100644 --- a/src/main/java/net/limework/rediskript/skript/elements/EffSendMessage.java +++ b/src/main/java/net/limework/rediskript/skript/elements/EffSendMessage.java @@ -49,17 +49,17 @@ public class EffSendMessage extends Effect { json.put("Date", System.currentTimeMillis()); //for unique string every time & PING calculations byte[] msg; RedisManager manager = plugin.getRm(); - if (manager.getEncryption().isEncryptionEnabled()) { msg = manager.getEncryption().encrypt(json.toString()); } else { msg = json.toString().getBytes(StandardCharsets.UTF_8); } try { - BinaryJedis j = manager.getJedisPool().getResource(); - - j.publish(channel.getBytes(StandardCharsets.UTF_8), msg); - j.close(); + manager.getRedisService().execute(() -> { + BinaryJedis j = manager.getJedisPool().getResource(); + j.publish(channel.getBytes(StandardCharsets.UTF_8), msg); + j.close(); + }); } catch (JedisConnectionException exception) { exception.printStackTrace(); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7917538..b8160e3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -main: net.limework.core.RediSkript +main: net.limework.rediskript.RediSkript name: RediSkript version: ${project.version} authors: [Govindas, ham1255, DaemonicKing]