mirror of
https://github.com/Example-uPagge/quarkus-kafka-panache.git
synced 2024-06-14 11:52:55 +03:00
Добавил новый способ решения проблемы
This commit is contained in:
parent
84a83cd574
commit
cbcc5117c5
@ -19,7 +19,6 @@ public class KafkaMessageGenerator {
|
|||||||
this.telegramChannel = telegramChannel;
|
this.telegramChannel = telegramChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(@Observes StartupEvent ev) {
|
public void start(@Observes StartupEvent ev) {
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
final KafkaMessage kafkaMessage = new KafkaMessage();
|
final KafkaMessage kafkaMessage = new KafkaMessage();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||||
<quarkus.platform.version>2.11.2.Final</quarkus.platform.version>
|
<quarkus.platform.version>2.14.0.Final</quarkus.platform.version>
|
||||||
<skipITs>true</skipITs>
|
<skipITs>true</skipITs>
|
||||||
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
|
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -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<Void> handle(KafkaMessage message) {
|
||||||
|
System.out.println("Получено сообщение " + message);
|
||||||
|
final EntityForDb entityForDb = new EntityForDb();
|
||||||
|
entityForDb.setCount(message.getCount());
|
||||||
|
return panacheRepository.persistAndFlush(entityForDb).replaceWithVoid();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,14 +5,16 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.eclipse.microprofile.reactive.messaging.Incoming;
|
import org.eclipse.microprofile.reactive.messaging.Incoming;
|
||||||
|
|
||||||
import javax.enterprise.context.ApplicationScoped;
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import javax.enterprise.context.control.ActivateRequestContext;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class KafkaHandler {
|
public class KafkaHandlerForOldVersion {
|
||||||
|
|
||||||
private final EntityRepositoryImpl panacheRepository;
|
private final EntityRepositoryImpl panacheRepository;
|
||||||
|
|
||||||
@Incoming("test")
|
@Incoming("test")
|
||||||
|
@ActivateRequestContext
|
||||||
public Uni<Void> handle(KafkaMessage message) {
|
public Uni<Void> handle(KafkaMessage message) {
|
||||||
System.out.println("Получено сообщение " + message);
|
System.out.println("Получено сообщение " + message);
|
||||||
final EntityForDb entityForDb = new EntityForDb();
|
final EntityForDb entityForDb = new EntityForDb();
|
@ -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<EntityForDb> {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user