Skip to content

KafkaProducer creation blocks Vert.x event loop when brokers are unreachable #777

Description

@mcweba

When updating the topicsConfig resource, the KafkaProducer is created synchronously on the Vert.x event loop thread. If Kafka brokers are unreachable due to network issues, firewall settings, or DNS problems, the producer creation blocks, causing the entire application to become unresponsive.

Root Cause:

In KafkaProducerRepository.addKafkaProducer(), KafkaProducer.create(vertx, config) is called directly without wrapping it in vertx.executeBlocking(). The call chain from config resource change notification runs entirely on the event loop:

ConfigurationResourceManager (event bus consumer)
→ KafkaHandler.resourceChanged()
→ KafkaHandler.initializeKafkaConfiguration()
→ KafkaProducerRepository.addKafkaProducer()
→ KafkaProducer.create() ← blocking call on event loop

Impact:

  • Complete application freeze when topicsConfig is updated and Kafka brokers are unreachable
  • All HTTP requests hang until the Kafka client times out (which can take minutes)
  • No graceful degradation or error handling

Suggested Fix:

Wrap KafkaProducer.create() in vertx.executeBlocking() to offload potentially blocking operations to a worker thread

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions