Spring Kafka consumer stops consuming after 1–2 days with ExpiringCredentialRefreshingLogin logs
04:18 15 Dec 2025

I have a Spring Kafka application with a single consumer. The Kafka client authentication is configured using SASL/OAUTHBEARER over SSL, as shown below:

       authProps.put(SaslConfigs.SASL_MECHANISM, "OAUTHBEARER");
       authProps.put(SaslConfigs.SASL_JAAS_CONFIG, buildJaasConfig());
       authProps.put(SaslConfigs.SASL_LOGIN_CALLBACK_HANDLER_CLASS, saslLoginHandlerClass);
       authProps.put(SaslConfigs.SASL_OAUTHBEARER_TOKEN_ENDPOINT_URL, saslOauthbreakerTokenEndpoint);

The service is deployed as a container image on an Azure AKS pod. I receive the following log every hour when the OAuth token is refreshed. However, after 1–2 days, although the service does not terminate, the Kafka consumer stops consuming messages. It works perfectly for 1-2 days but then stops consuming.

What could be the reasons of my consumer getting terminated/killed/disconnected by the broker.?

2025-12-15 07:16:47.036 INFO  [kafka-expiring-relogin-thread-xxxxxx] o.a.k.c.s.o.i.e.ExpiringCredentialRefreshingLogin:389 - Initiating re-login for xxxxxx-xxxxxx-xxxxxx, logout() still needs to be called on a previous login = true
2025-12-15 07:16:47.249 INFO  [kafka-expiring-relogin-thread-xxxxxx] o.a.k.c.s.o.i.e.ExpiringCredentialRefreshingLogin:319 - [Principal=xxxxxx-xxxxxx-xxxxxx]: Expiring credential valid from Mon Dec 15 07:11:47 UTC 2025 to Mon Dec 15 08:16:47 UTC 2025
2025-12-15 07:16:47.262 INFO  [kafka-expiring-relogin-thread-xxxxxx] o.a.k.c.s.o.i.e.ExpiringCredentialRefreshingLogin$Refresher:92 - [Principal=:f72a5d45-3737-42d4-b1be-b4698f2282ef]: Expiring credential re-login sleeping until: Mon Dec 15 08:06:40 UTC 2025

In addition to the above, there is a map variable in the consumer class that is updated inside the consume() method and is read accordingly by one of the spring scheduler classes. It is declared as a ConcurrentHashMap to avoid race conditions.

azure ssl apache-kafka spring-kafka azure-oauth