Manish Kumar
Manish Kumar

Reputation: 7179

kafka AdminClient not working in deployed environment

I am using spring kafka to connect to kafka and to check the status of the kafka server, I am using org.apache.kafka.clients.admin.AdminClient. It is working fine in my local but but when I deploy into QA environment, it doesn't start, complaining not able to create AdminClient bean. My guess is that AdminClient would be using any specific port, which would not be open in QA environment.

Does someone know if this is the case and which port KafkaAdmin connect to? Spring kafka without KafkaAdmin seems to be working fine.

Upvotes: 1

Views: 2905

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121272

There is nothing special. The KafkaAdmin is based on some provided config:

/**
 * Create an instance with an {@link AdminClient} based on the supplied
 * configuration.
 * @param config the configuration for the {@link AdminClient}.
 */
public KafkaAdmin(Map<String, Object> config) {

This config is indeed use for the AdminClient internal instance:

 adminClient = AdminClient.create(this.config);

and that one is based on the AdminClientConfig:

/**
 * Create a new AdminClient with the given configuration.
 *
 * @param conf The configuration.
 * @return The new KafkaAdminClient.
 */
public static AdminClient create(Map<String, Object> conf) {
    return KafkaAdminClient.createInternal(new AdminClientConfig(conf), null);
}

So, all the properties required for AdminClient connection you can find in that AdminClientConfig. And pay attention that host/port by default is exactly the same as it is for any other clients:

public static final String BOOTSTRAP_SERVERS_CONFIG = CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG;

and

private static final String BOOTSTRAP_SERVERS_DOC = CommonClientConfigs.BOOTSTRAP_SERVERS_DOC;

So, when you create a KafkaAdmin instance, you should provide at least that bootstrap.servers property.

Also would be great to see a stack trace which happens in that mentioned environment.

Upvotes: 1

Related Questions