shiva789
shiva789

Reputation: 11

Getting IAMClientCallbackHandler class not found exception randomly for some messages

In our usecase currently we send messages one by one [ not in batch ] to maintain incoming order sequence while sending around more than 5000 messages one by one or sending a single message using kafkatemplate send method we are getting below error message

Exception while sending record to Kafka: Invalid value software.amazon.msk.auth.iam.IAMClientCallbackHandler for configuration sasl.client.callback.handler.class: Class software.amazon.msk.auth.iam.IAMClientCallbackHandler could not be found."}
org.apache.kafka.common.config.ConfigException: Invalid value software.amazon.msk.auth.iam.IAMClientCallbackHandler for configuration sasl.client.callback.handler.class: Class software.amazon.msk.auth.iam.IAMClientCallbackHandler could not be found. 

Out of 5000 records around 500 messages will be pushed to kafka and rest of the messages will be failed due to above error. We use aws managed kafka service from aws which is IAM enabled. aws-msk-iam-auth - 1.1.6 jar [ Observed same issue with 1.1.5 ] Producer config properties producerConfig.put("security.protocol","SASL_SSL"); producerConfig.put("sasl.mechanism","AWS_MSK_IAM"); producerConfig.put("sasl.jaas.config","software.amazon.msk.auth.iam.IAMLoginModule required;"); producerConfig.put("sasl.client.callback.handler.class","software.amazon.msk.auth.iam.IAMClientCallbackHandler"); Tried with adding aws-msk-iam-auth explicitly in the classpath.

Any help/suggestion will be helpful.

Upvotes: 0

Views: 624

Answers (2)

cristianhoyos66
cristianhoyos66

Reputation: 99

I fixed the same issue thanks to this response

I twas a bit unclear, but the solution is specifically this producerConfig.put("sasl.client.callback.handler.class",IAMClientCallbackHandler.class);

Notice the IAMClientCallbackHandler.class instead of "software.amazon.msk.auth.iam.IAMClientCallbackHandler"

Upvotes: 0

Sunil Chormale
Sunil Chormale

Reputation: 23

Try this:

import software.amazon.msk.auth.iam.IAMClientCallbackHandler;

producerConfig.put("security.protocol","SASL_SSL");
producerConfig.put("sasl.mechanism","AWS_MSK_IAM");
producerConfig.put("sasl.jaas.config","software.amazon.msk.auth.iam.IAMLoginModule required;");
producerConfig.put("sasl.client.callback.handler.class",IAMClientCallbackHandler.class); 

it will work!

Upvotes: 1

Related Questions