Skip to content

Quarkus Kafka

DodaTech 1 min read

In this tutorial, you'll learn about Fix Quarkus Kafka Connector Not Receiving. We cover key concepts, practical examples, and best practices.

The Problem

Kafka messages are not received by Quarkus Reactive Messaging consumers.

Quick Fix

Add Kafka connector

Wrong:

<!-- No kafka connector -->

Output:

No Kafka support

Right:

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
</dependency>

Output:

Kafka messaging enabled

Configure incoming channel

Wrong:

# No channel config
mp.messaging.incoming.products.connector=smallrye-kafka

Output:

No binding

Right:

mp.messaging.incoming.products.connector=smallrye-kafka
mp.messaging.incoming.products.topic=product-events
mp.messaging.incoming.products.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer

Output:

Channel configured

Use @Incoming annotation

Wrong:

// No consumer

Output:

No messages consumed

Right:

@ApplicationScoped
public class ProductConsumer {
    @Incoming("products")
    public void consume(String message) { }
}

Output:

Consumer created

Prevention

  • Add quarkus-smallrye-reactive-messaging-kafka dependency
  • Configure incoming/outgoing channels in application.properties
  • Use @Incoming and @Outgoing annotations

Common Mistakes with kafka

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world QUARKUS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does my consumer not receive messages?

Ensure the channel name matches between @Incoming and mp.messaging.incoming..topic.

This quick fix is part of the DodaTech Spring & JVM ecosystem series. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro