0

I have the same issue No serviceName defined in either JAAS or Kafka config (not Kerberos) but I can't solve it at all.

I'm trying to create org.apache.kafka.clients.admin.AdminClient using properties when application startup:

public void init(@Observes @Priority(Interceptor.Priority.APPLICATION) StartupEvent event) {
    log.info("Kafka startup event started!");
    
    Map<String, Object> properties = Map.of(
        "sasl.jaas.config", "org.apache.kafka.common.security.scram.ScramLoginModule required username=user password=user;",
        AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "...",
        "sasl.jaas.mechanism", "SCRAM-SHA-512",
        "security.protocol", "SASL_PLAINTEXT"
    );
    int partitions = 1;
    short replicationFactor = 1;

    NewTopic topic = new NewTopic("test-topic-name", partitions, replicationFactor);

    try (AdminClient adminClient = AdminClient.create(properties)) {
        CreateTopicsResult result = adminClient.createTopics(
            Collections.singleton(topic)
        );
        KafkaFuture<Void> future = result.values().get(topic);

        future.get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
}

And also have properties from application.yaml:

kafka:
 auto:
    create:
      topics:
        enable: false
  bootstrap:
    servers: {servers}
  sasl:
    jaas:
      config: org.apache.kafka.common.security.scram.ScramLoginModule required username=user password=user;
    mechanism: SCRAM-SHA-512
  security:
    protocol: SASL_PLAINTEXT

If I use only properties that's set from appl.yaml only - it's ok, but when I tried to use manually creation topic to clarify properties from MAP - had an issue. I tried to specify serviceName from sasl.jaas.config like

org.apache.kafka.common.security.scram.ScramLoginModule required username=user password=user serviceName=Kafka;

But I still have an issue , but with authorization. How can I create topic when startup only? Not using LAZY initialization. It's my main goal.

Used quarkus, apache kafka.

https://www.baeldung.com/kafka-topic-creation

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Disteonne
  • 59
  • 1
  • 8

1 Answers1

1

By refactoring the key "sasl.jaas.mechanism" to "sasl.mechanism" it should work again.

spi-x-i
  • 287
  • 1
  • 12