<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nagarajan Selvaraj</title>
    <description>The latest articles on DEV Community by Nagarajan Selvaraj (@nagarajan).</description>
    <link>https://dev.to/nagarajan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F232817%2Fd6fed0b3-db0f-4201-9d50-9b932f6ef0dc.jpg</url>
      <title>DEV Community: Nagarajan Selvaraj</title>
      <link>https://dev.to/nagarajan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nagarajan"/>
    <language>en</language>
    <item>
      <title>Kafka producer retries in Spring kafka</title>
      <dc:creator>Nagarajan Selvaraj</dc:creator>
      <pubDate>Mon, 23 Sep 2019 16:55:42 +0000</pubDate>
      <link>https://dev.to/nagarajan/kafka-producer-retries-in-spring-kafka-49fl</link>
      <guid>https://dev.to/nagarajan/kafka-producer-retries-in-spring-kafka-49fl</guid>
      <description>&lt;p&gt;The KafkaProducer configuration has a option(&lt;em&gt;retries&lt;/em&gt; property) for doing automatic retries in case of RetriableExceptions like NoLeaderForPartition, NetworkException, TimeoutException etc.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;retries&lt;/strong&gt; property has the default value as &lt;strong&gt;Integer.MAX&lt;/strong&gt; as per &lt;em&gt;&lt;a href="https://kafka.apache.org/documentation/#producerconfigs"&gt;https://kafka.apache.org/documentation/#producerconfigs&lt;/a&gt;&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;I was using &lt;em&gt;spring-kafka 2.2.8-RELEASE&lt;/em&gt; in the application and tried to test the retry behavior by bringing one of the broker down from the Kafka cluster. It thrown the NoLeaderForPartition exception as the leader broker for a partition went down and it took 1-2 seconds for a new leader to be assigned to that partition.&lt;/p&gt;

&lt;p&gt;As per the documentation, the producer should’ve retried on this exception, but to the surprise it didn’t happen. Digging further, found out that the spring-kafka 2.2.8-RELEASE (Aug 2019, latest in central repo) is using 2.0.1 version of &lt;em&gt;kafka-clients&lt;/em&gt; library whereas the kafka-clients library’s latest version is 2.3.0. In kafka-clients 2.0.1 version, the default value for retries is 0.&lt;/p&gt;

&lt;p&gt;Learning I take away from this is that the &lt;em&gt;latest spring library version need not be using the latest version&lt;/em&gt; of the actual client library. Also we need to understand from which version of the client library, the documentation applies to.&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>spring</category>
      <category>java</category>
    </item>
  </channel>
</rss>
