Restored working but it needs to be run on the same wsl box.

This commit is contained in:
Tomasz Półgrabia 2024-12-27 22:00:03 +01:00
parent 4ad8473aaa
commit a6ea81505c
3 changed files with 10 additions and 7 deletions

View file

@ -1,10 +1,13 @@
package ch.polgrabia.demos.server;
import io.vertx.core.Vertx;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import java.util.Properties;
public class WebsocketServerApp {
public static void main(String[] args) {
/**
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("linger.ms", 1);
@ -12,7 +15,7 @@ public class WebsocketServerApp {
props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
Producer<String, byte[]> kafkaProducer = new KafkaProducer<>(props);
**/
var vertx = Vertx.vertx();
WebsocketServerChatVerticle websocketServerChatVerticle = new WebsocketServerChatVerticle(
@ -24,6 +27,6 @@ public class WebsocketServerApp {
.waitUntilFinished()
.join();
vertx.close();
// kafkaProducer.close();
kafkaProducer.close();
}
}

View file

@ -71,7 +71,7 @@ public class WebsocketServerHandler implements Handler<ServerWebSocket> {
String channel = serverWebSocket.path();
logger.info("[{}] Got message {}", channel, s);
serverWebSocket.writeBinaryMessage(Buffer.buffer("Pong: " + s.toString() + "\n")); // TBD send to kafka
// kafkaProducer.send(new ProducerRecord<>(channel, channel, s.getBytes())); // kafka setup needs to be checked
kafkaProducer.send(new ProducerRecord<>(channel, channel, s.getBytes())); // kafka setup needs to be checked
}
}