fix: наименование групп kafka
This commit is contained in:
@@ -21,8 +21,11 @@ public class MainPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initKafkaService() {
|
private void initKafkaService() {
|
||||||
|
ClassLoader originalContext = Thread.currentThread().getContextClassLoader();
|
||||||
|
Thread.currentThread().setContextClassLoader(null);
|
||||||
//FIXME перенести в конфигурацию
|
//FIXME перенести в конфигурацию
|
||||||
service = new KafkaService("127.0.0.1:9092", "global-chat", 1000);
|
service = new KafkaService("127.0.0.1:9092", "global-chat", 1000);
|
||||||
|
Thread.currentThread().setContextClassLoader(originalContext);
|
||||||
|
|
||||||
mqThread = new Thread(() -> {
|
mqThread = new Thread(() -> {
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (!Thread.currentThread().isInterrupted()) {
|
||||||
|
|||||||
@@ -62,19 +62,23 @@ public class KafkaService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
consumer.commitAsync();
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
producer.close();
|
||||||
producer = null;
|
producer = null;
|
||||||
consumer.unsubscribe();
|
|
||||||
|
consumer.close();
|
||||||
consumer = null;
|
consumer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Consumer<Long, String> createConsumer() {
|
private Consumer<Long, String> createConsumer() {
|
||||||
final Properties props = new Properties();
|
final Properties props = new Properties();
|
||||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, hosts);
|
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, hosts);
|
||||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "DefaultGroup");
|
props.put(ConsumerConfig.GROUP_ID_CONFIG, "WithoutGroup." + UUID.randomUUID().toString());
|
||||||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class.getName());
|
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class.getName());
|
||||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user