quarkus: Problem with quarkus kafka smallrye consumer multithreading
Describe the bug
By setting “partitions” parameter to 3. I have 3 different consumer ids, but the messages are processed sequentially.
- quarkus version 2.X
- smallrye
Properties that i set
mp:
messaging:
incoming:
event:
connector: smallrye-kafka
auto:
offset:
reset: earliest
topic: MY_TOPIC
group:
id: my-group
partitions: 3
Expected behavior
the messages should be processed concurrently for each partition
Actual behavior
the messages are processed sequentialy though we have different partitions
Output of java -version
jdk11
Quarkus version or git rev
2.4.1
Build tool (ie. output of mvnw --version or gradlew --version)
3.6.3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 26 (12 by maintainers)
No, the documentation is right, it just does not do the dispatching as you describe it, and will still serialize the records following the reactive streams semantic.
Another solution is something like:
Note that even with this, the emission will still be serialized. They would be multi-threaded, but serialized. You may want to do something like:
so, the processing is running on the different threads.
You can try with the low-level kafka client, but it’s a rabbit hole.
hi, so the guide it’s wrong? https://quarkus.io/guides/kafka paragraph 4.5 -> 2
@davideginna Thanks for the reproducer. Your tests are running on quarkus version 2.2.1.Final which had an issue with the
@Blockinghandling. Starting from2.4.0.Finalyou shouldn’t have the issue anymore. BTW here are couple more issues I noticed:ResourceConsumer.javathe incoming method should subscribe to the channelevent, the incoming channel you configured, instead ofsender.@Broadcaston the producer.message.getMetadata(IncomingKafkaRecordMetadata.class). Previously you were accessing the outgoing metadata of the message transmitted through the in-memory channel not Kafka.Hope this helps.