diff --git a/quarkus-kafka-panache-generator/src/main/java/dev/struchkov/example/quarkus/generator/KafkaMessageGenerator.java b/quarkus-kafka-panache-generator/src/main/java/dev/struchkov/example/quarkus/generator/KafkaMessageGenerator.java index dad2c60..b28380b 100644 --- a/quarkus-kafka-panache-generator/src/main/java/dev/struchkov/example/quarkus/generator/KafkaMessageGenerator.java +++ b/quarkus-kafka-panache-generator/src/main/java/dev/struchkov/example/quarkus/generator/KafkaMessageGenerator.java @@ -19,7 +19,6 @@ public class KafkaMessageGenerator { this.telegramChannel = telegramChannel; } - public void start(@Observes StartupEvent ev) { for (int i = 0; i < 50; i++) { final KafkaMessage kafkaMessage = new KafkaMessage(); diff --git a/quarkus-kafka-panache-problem/pom.xml b/quarkus-kafka-panache-problem/pom.xml index 009e42d..e6baba8 100644 --- a/quarkus-kafka-panache-problem/pom.xml +++ b/quarkus-kafka-panache-problem/pom.xml @@ -15,7 +15,7 @@ UTF-8 quarkus-bom io.quarkus.platform - 2.11.2.Final + 2.14.0.Final true 3.0.0-M7 diff --git a/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForNewVersion.java b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForNewVersion.java new file mode 100644 index 0000000..cd25d9b --- /dev/null +++ b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForNewVersion.java @@ -0,0 +1,25 @@ +package dev.struchkov.example.quarkus.kafka; + +import io.smallrye.mutiny.Uni; +import lombok.RequiredArgsConstructor; +import org.eclipse.microprofile.reactive.messaging.Incoming; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.control.ActivateRequestContext; + +@ApplicationScoped +@RequiredArgsConstructor +public class KafkaHandlerForNewVersion { + + private final PanacheRepositoryImpl panacheRepository; + + @Incoming("test") + @ActivateRequestContext + public Uni handle(KafkaMessage message) { + System.out.println("Получено сообщение " + message); + final EntityForDb entityForDb = new EntityForDb(); + entityForDb.setCount(message.getCount()); + return panacheRepository.persistAndFlush(entityForDb).replaceWithVoid(); + } + +} diff --git a/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandler.java b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForOldVersion.java similarity index 83% rename from quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandler.java rename to quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForOldVersion.java index 4391db5..b918072 100644 --- a/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandler.java +++ b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/KafkaHandlerForOldVersion.java @@ -5,14 +5,16 @@ import lombok.RequiredArgsConstructor; import org.eclipse.microprofile.reactive.messaging.Incoming; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.control.ActivateRequestContext; @ApplicationScoped @RequiredArgsConstructor -public class KafkaHandler { +public class KafkaHandlerForOldVersion { private final EntityRepositoryImpl panacheRepository; @Incoming("test") + @ActivateRequestContext public Uni handle(KafkaMessage message) { System.out.println("Получено сообщение " + message); final EntityForDb entityForDb = new EntityForDb(); diff --git a/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/PanacheRepositoryImpl.java b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/PanacheRepositoryImpl.java new file mode 100644 index 0000000..8bc3f87 --- /dev/null +++ b/quarkus-kafka-panache-problem/src/main/java/dev/struchkov/example/quarkus/kafka/PanacheRepositoryImpl.java @@ -0,0 +1,10 @@ +package dev.struchkov.example.quarkus.kafka; + +import io.quarkus.hibernate.reactive.panache.PanacheRepository; + +import javax.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class PanacheRepositoryImpl implements PanacheRepository { + +}