Akka streams Kafka consumer process parallel

851 Views Asked by At

I’m working on a Kafka consumer application using Akka Kafka connector. I would like the consumer to process messages parallelly. which consumer group should I choose Choosing a consumer? how can I configure the parallelism on the consumer side?

1

There are 1 best solutions below

0
On

There are different levels of "parallelism" when you talk about Kafka and then akka-stream.

Kafka processing can be paralleled by introduction of multiple partitions in a topic and having a single Kafka consumer consuming from a singe partition all of the messages in a sequential order, ie messages in the order of their sequence id or offset. This allows for multiple consumers consuming from multiple partitions simultaneously.

Akka streams has a very sequential approach and it does processing in a one by one manner by default. But this of course depends on your interconnected flows. I strongly suggest reading this to understand how threading and concurrency are used in akka-stream.

The answer to your question is that parallelism depends on all of these aspects and not on choosing the correct akka stream "Consumer" (I would call it a Source in akka stream terms), which mostly defines access to offset that can be committed after processing.