[SIS-14] adding the on message in its own thread

This commit is contained in:
Sheldan
2022-12-10 19:00:21 +01:00
parent 7e3b23aec0
commit 127ff821d1

View File

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static dev.sheldan.sissi.module.debra.config.DebraFeatureConfig.DEBRA_DONATION_NOTIFICATION_DELAY_CONFIG_KEY; import static dev.sheldan.sissi.module.debra.config.DebraFeatureConfig.DEBRA_DONATION_NOTIFICATION_DELAY_CONFIG_KEY;
@@ -40,6 +41,7 @@ public class WebsocketListener extends WebSocketListener implements AsyncStartup
@Override @Override
public void onMessage(WebSocket webSocket, String text) { public void onMessage(WebSocket webSocket, String text) {
CompletableFuture.runAsync(() -> {
log.info("Handling received message on websocket."); log.info("Handling received message on websocket.");
try { try {
Long targetServerId = Long.parseLong(System.getenv(DEBRA_DONATION_NOTIFICATION_SERVER_ID_ENV_NAME)); Long targetServerId = Long.parseLong(System.getenv(DEBRA_DONATION_NOTIFICATION_SERVER_ID_ENV_NAME));
@@ -57,6 +59,7 @@ public class WebsocketListener extends WebSocketListener implements AsyncStartup
} catch (Exception exception) { } catch (Exception exception) {
log.error("Failed to handle websocket message.", exception); log.error("Failed to handle websocket message.", exception);
} }
});
} }
@Override @Override