The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Servicios de desarrollo para Kafka

If any Kafka-related extension is present (e.g. quarkus-messaging-kafka), Dev Services for Kafka automatically starts a Kafka broker in dev mode and when running tests. So, you don’t have to start a broker manually. The application is configured automatically.

Because starting a Kafka broker can be long, Dev Services for Kafka uses Redpanda, a Kafka compatible broker which starts in ~1 second.

Activación/desactivación de los servicios de desarrollo para Kafka

Los servicios de desarrollo para Kafka se activan automáticamente a menos que:

  • quarkus.kafka.devservices.enabled se ajusta a false

  • el kafka.bootstrap.servers está configurado

  • todos los canales de Kafka de Mensajería Reactiva tienen el atributo bootstrap.servers establecido

Dev Services for Kafka relies on Docker to start the broker. If your environment does not support Docker, you will need to start the broker manually, or connect to an already running broker. You can configure the broker address using kafka.bootstrap.servers.

Broker compartido

Most of the time you need to share the broker between applications. Dev Services for Kafka implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single broker.

Dev Services for Kafka inicia el contenedor con la etiqueta quarkus-dev-service-kafka que se utiliza para identificar el contenedor.

If you need multiple (shared) brokers, you can configure the quarkus.kafka.devservices.service-name attribute and indicate the broker name. It looks for a container with the same value, or starts a new one if none can be found. The default service name is kafka.

Sharing is enabled by default in dev mode, but disabled in test mode. You can disable the sharing with quarkus.kafka.devservices.shared=false.

Ajuste del puerto

By default, Dev Services for Kafka picks a random port and configures the application. You can set the port by configuring the quarkus.kafka.devservices.port property.

Tenga en cuenta que la dirección anunciada de Kafka se configura automáticamente con el puerto elegido.

Configuración de la imagen

Dev Services for Kafka supports Redpanda, kafka-native and Strimzi (in Kraft mode) images.

Redpanda is a Kafka compatible event streaming platform. Because it provides a fast startup times, dev services defaults to Redpanda images from vectorized/redpanda. You can select any version from https://hub.docker.com/r/vectorized/redpanda.

kafka-native provides images of standard Apache Kafka distribution compiled to native binary using Quarkus and GraalVM. While still being experimental, it provides very fast startup times with small footprint.

Image type can be configured using

quarkus.kafka.devservices.provider=kafka-native

Strimzi provides container images and Operators for running Apache Kafka on Kubernetes. While Strimzi is optimized for Kubernetes, the images work perfectly in classic container environments. Strimzi container images run "genuine" Kafka broker on JVM, which is slower to start.

quarkus.kafka.devservices.provider=strimzi

Para Strimzi, puede seleccionar cualquier imagen con una versión de Kafka que tenga soporte para Kraft (2.8.1 y superior) desde https://quay.io/repository/strimzi-test-container/test-container?tab=tags

quarkus.kafka.devservices.image-name=quay.io/strimzi-test-container/test-container:0.105.0-kafka-3.6.0

Configuración de los temas de Kafka

You can configure the Dev Services for Kafka to create topics once the broker is started. Topics are created with given number of partitions and 1 replica.

El siguiente ejemplo crea un tema llamado test con 3 particiones, y un segundo tema llamado messages con 2 particiones.

quarkus.kafka.devservices.topic-partitions.test=3
quarkus.kafka.devservices.topic-partitions.messages=2

If a topic already exists with the given name, the creation is skipped, without trying to re-partition the existing topic to a different number of partitions.

Puede configurar el tiempo de espera para las llamadas del cliente Kafka admin utilizadas en la creación de temas utilizando quarkus.kafka.devservices.topic-partitions-timeout, por defecto es de 2 segundos.

Transactional and Idempotent producers support

By default, the Redpanda broker is configured to enable transactions and idempotence features. You can disable those using:

quarkus.kafka.devservices.redpanda.transaction-enabled=false
Redpanda transactions does not support exactly-once processing.