Performance regression when using Hibernate with reactive message queues #45792
-
We designed a Quarkus service that makes use of REST, Hibernate ORM and messaging. We deliberately decided to step away from mutiny so we are not using that here. There is a very specific guide page in the documentation: https://quarkus.io/guides/kafka#writing-entities-managed-by-hibernate-to-kafka This is essentially our use case. It is of course a bit more complex/larger, but it essentially boils down to:
The documentation suggests this: @Path("/")
public class ResourceSendingToKafka {
@Channel("kafka") Emitter<Fruit> emitter;
@POST
@Path("/fruits")
@Transactional
public CompletionStage<Void> storeAndSendToKafka(Fruit fruit) {
fruit.persist();
return emitter.send(new FruitDto(fruit));
}
} However this creates an annoying performance regression for us (which took us some time to debug): |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
/cc @DavideD (hibernate-reactive), @gavinking (hibernate-reactive) |
Beta Was this translation helpful? Give feedback.
-
One solution would be to do something like: @Path("/")
public class ResourceSendingToKafka {
@Channel("kafka") Emitter<Fruit> emitter;
@POST
@Path("/fruits")
@Blocking
public CompletionStage<Void> storeAndSendToKafka(Fruit fruit) {
store(fruit)
return emitter.send(new FruitDto(fruit));
}
@Transactional
private void store(Fruit fruit) {
fruit.persist();
}
} But this goes against the Quarkus recommendation of putting |
Beta Was this translation helpful? Give feedback.
Try with:
Or, if you don't care about the Kafka emission (and don't want to wait for the ack from the broker) you can either:
ack
to 0