3434import org .apache .kafka .common .serialization .StringSerializer ;
3535
3636import org .springframework .boot .context .properties .ConfigurationProperties ;
37+ import org .springframework .boot .context .properties .DeprecatedConfigurationProperty ;
3738import org .springframework .boot .context .properties .PropertyMapper ;
3839import org .springframework .boot .context .properties .source .MutuallyExclusiveConfigurationPropertiesException ;
3940import org .springframework .boot .convert .DurationUnit ;
@@ -1547,28 +1548,6 @@ public static class Topic {
15471548 */
15481549 private int attempts = 3 ;
15491550
1550- /**
1551- * Canonical backoff period. Used as an initial value in the exponential case,
1552- * and as a minimum value in the uniform case.
1553- */
1554- private Duration delay = Duration .ofSeconds (1 );
1555-
1556- /**
1557- * Multiplier to use for generating the next backoff delay.
1558- */
1559- private double multiplier = 0.0 ;
1560-
1561- /**
1562- * Maximum wait between retries. If less than the delay then the default of 30
1563- * seconds is applied.
1564- */
1565- private Duration maxDelay = Duration .ZERO ;
1566-
1567- /**
1568- * Whether to have the backoff delays.
1569- */
1570- private boolean randomBackOff = false ;
1571-
15721551 public boolean isEnabled () {
15731552 return this .enabled ;
15741553 }
@@ -1585,36 +1564,113 @@ public void setAttempts(int attempts) {
15851564 this .attempts = attempts ;
15861565 }
15871566
1567+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.delay" , since = "3.4.0" )
1568+ @ Deprecated (since = "3.4.0" , forRemoval = true )
15881569 public Duration getDelay () {
1589- return this . delay ;
1570+ return getBackoff (). getDelay () ;
15901571 }
15911572
1573+ @ Deprecated (since = "3.4.0" , forRemoval = true )
15921574 public void setDelay (Duration delay ) {
1593- this . delay = delay ;
1575+ getBackoff (). setDelay ( delay ) ;
15941576 }
15951577
1578+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.multiplier" ,
1579+ since = "3.4.0" )
1580+ @ Deprecated (since = "3.4.0" , forRemoval = true )
15961581 public double getMultiplier () {
1597- return this . multiplier ;
1582+ return getBackoff (). getMultiplier () ;
15981583 }
15991584
1585+ @ Deprecated (since = "3.4.0" , forRemoval = true )
16001586 public void setMultiplier (double multiplier ) {
1601- this . multiplier = multiplier ;
1587+ getBackoff (). setMultiplier ( multiplier ) ;
16021588 }
16031589
1590+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.maxDelay" , since = "3.4.0" )
1591+ @ Deprecated (since = "3.4.0" , forRemoval = true )
16041592 public Duration getMaxDelay () {
1605- return this . maxDelay ;
1593+ return getBackoff (). getMaxDelay () ;
16061594 }
16071595
1596+ @ Deprecated (since = "3.4.0" , forRemoval = true )
16081597 public void setMaxDelay (Duration maxDelay ) {
1609- this . maxDelay = maxDelay ;
1598+ getBackoff (). setMaxDelay ( maxDelay ) ;
16101599 }
16111600
1601+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.random" , since = "3.4.0" )
1602+ @ Deprecated (since = "3.4.0" , forRemoval = true )
16121603 public boolean isRandomBackOff () {
1613- return this . randomBackOff ;
1604+ return getBackoff (). isRandom () ;
16141605 }
16151606
1607+ @ Deprecated (since = "3.4.0" , forRemoval = true )
16161608 public void setRandomBackOff (boolean randomBackOff ) {
1617- this .randomBackOff = randomBackOff ;
1609+ getBackoff ().setRandom (randomBackOff );
1610+ }
1611+
1612+ private final Backoff backoff = new Backoff ();
1613+
1614+ public Backoff getBackoff () {
1615+ return this .backoff ;
1616+ }
1617+
1618+ public static class Backoff {
1619+
1620+ /**
1621+ * Canonical backoff period. Used as an initial value in the exponential
1622+ * case, and as a minimum value in the uniform case.
1623+ */
1624+ private Duration delay = Duration .ofSeconds (1 );
1625+
1626+ /**
1627+ * Multiplier to use for generating the next backoff delay.
1628+ */
1629+ private double multiplier = 0.0 ;
1630+
1631+ /**
1632+ * Maximum wait between retries. If less than the delay then the default
1633+ * of 30 seconds is applied.
1634+ */
1635+ private Duration maxDelay = Duration .ZERO ;
1636+
1637+ /**
1638+ * Whether to have the backoff delays.
1639+ */
1640+ private boolean random = false ;
1641+
1642+ public Duration getDelay () {
1643+ return this .delay ;
1644+ }
1645+
1646+ public void setDelay (Duration delay ) {
1647+ this .delay = delay ;
1648+ }
1649+
1650+ public double getMultiplier () {
1651+ return this .multiplier ;
1652+ }
1653+
1654+ public void setMultiplier (double multiplier ) {
1655+ this .multiplier = multiplier ;
1656+ }
1657+
1658+ public Duration getMaxDelay () {
1659+ return this .maxDelay ;
1660+ }
1661+
1662+ public void setMaxDelay (Duration maxDelay ) {
1663+ this .maxDelay = maxDelay ;
1664+ }
1665+
1666+ public boolean isRandom () {
1667+ return this .random ;
1668+ }
1669+
1670+ public void setRandom (boolean random ) {
1671+ this .random = random ;
1672+ }
1673+
16181674 }
16191675
16201676 }
0 commit comments