so I found that this threadpool was actually needed, oops

due to it not having threadpool, froze my server at one point
This commit is contained in:
Govindas 2020-11-02 14:14:38 +02:00
parent 76b7166145
commit f35ad377d1
4 changed files with 10 additions and 8 deletions

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.limework.core</groupId> <groupId>net.limework.rediskript</groupId>
<artifactId>RediSkript</artifactId> <artifactId>RediSkript</artifactId>
<version>1.2.2</version> <version>1.2.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@ -52,7 +52,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
config.getInt("Redis.TimeOut"), config.getInt("Redis.TimeOut"),
config.getString("Redis.Password"), config.getString("Redis.Password"),
config.getBoolean("Redis.useTLS")); config.getBoolean("Redis.useTLS"));
RedisService = Executors.newSingleThreadExecutor(); RedisService = Executors.newFixedThreadPool(3);
try { try {
this.subscribeJedis = this.jedisPool.getResource(); this.subscribeJedis = this.jedisPool.getResource();
} catch (Exception ignored) { } catch (Exception ignored) {
@ -163,4 +163,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
public Encryption getEncryption() { public Encryption getEncryption() {
return encryption; return encryption;
} }
public ExecutorService getRedisService() { return RedisService; }
} }

View File

@ -49,17 +49,17 @@ public class EffSendMessage extends Effect {
json.put("Date", System.currentTimeMillis()); //for unique string every time & PING calculations json.put("Date", System.currentTimeMillis()); //for unique string every time & PING calculations
byte[] msg; byte[] msg;
RedisManager manager = plugin.getRm(); RedisManager manager = plugin.getRm();
if (manager.getEncryption().isEncryptionEnabled()) { if (manager.getEncryption().isEncryptionEnabled()) {
msg = manager.getEncryption().encrypt(json.toString()); msg = manager.getEncryption().encrypt(json.toString());
} else { } else {
msg = json.toString().getBytes(StandardCharsets.UTF_8); msg = json.toString().getBytes(StandardCharsets.UTF_8);
} }
try { try {
BinaryJedis j = manager.getJedisPool().getResource(); manager.getRedisService().execute(() -> {
BinaryJedis j = manager.getJedisPool().getResource();
j.publish(channel.getBytes(StandardCharsets.UTF_8), msg); j.publish(channel.getBytes(StandardCharsets.UTF_8), msg);
j.close(); j.close();
});
} catch (JedisConnectionException exception) { } catch (JedisConnectionException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }

View File

@ -1,4 +1,4 @@
main: net.limework.core.RediSkript main: net.limework.rediskript.RediSkript
name: RediSkript name: RediSkript
version: ${project.version} version: ${project.version}
authors: [Govindas, ham1255, DaemonicKing] authors: [Govindas, ham1255, DaemonicKing]