34
34
import org .apache .kafka .common .serialization .StringSerializer ;
35
35
36
36
import org .springframework .boot .context .properties .ConfigurationProperties ;
37
+ import org .springframework .boot .context .properties .DeprecatedConfigurationProperty ;
37
38
import org .springframework .boot .context .properties .PropertyMapper ;
38
39
import org .springframework .boot .context .properties .source .MutuallyExclusiveConfigurationPropertiesException ;
39
40
import org .springframework .boot .convert .DurationUnit ;
@@ -1547,28 +1548,6 @@ public static class Topic {
1547
1548
*/
1548
1549
private int attempts = 3 ;
1549
1550
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
-
1572
1551
public boolean isEnabled () {
1573
1552
return this .enabled ;
1574
1553
}
@@ -1585,36 +1564,113 @@ public void setAttempts(int attempts) {
1585
1564
this .attempts = attempts ;
1586
1565
}
1587
1566
1567
+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.delay" , since = "3.4.0" )
1568
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1588
1569
public Duration getDelay () {
1589
- return this . delay ;
1570
+ return getBackoff (). getDelay () ;
1590
1571
}
1591
1572
1573
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1592
1574
public void setDelay (Duration delay ) {
1593
- this . delay = delay ;
1575
+ getBackoff (). setDelay ( delay ) ;
1594
1576
}
1595
1577
1578
+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.multiplier" ,
1579
+ since = "3.4.0" )
1580
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1596
1581
public double getMultiplier () {
1597
- return this . multiplier ;
1582
+ return getBackoff (). getMultiplier () ;
1598
1583
}
1599
1584
1585
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1600
1586
public void setMultiplier (double multiplier ) {
1601
- this . multiplier = multiplier ;
1587
+ getBackoff (). setMultiplier ( multiplier ) ;
1602
1588
}
1603
1589
1590
+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.maxDelay" , since = "3.4.0" )
1591
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1604
1592
public Duration getMaxDelay () {
1605
- return this . maxDelay ;
1593
+ return getBackoff (). getMaxDelay () ;
1606
1594
}
1607
1595
1596
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1608
1597
public void setMaxDelay (Duration maxDelay ) {
1609
- this . maxDelay = maxDelay ;
1598
+ getBackoff (). setMaxDelay ( maxDelay ) ;
1610
1599
}
1611
1600
1601
+ @ DeprecatedConfigurationProperty (replacement = "spring.kafka.retry.topic.backoff.random" , since = "3.4.0" )
1602
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1612
1603
public boolean isRandomBackOff () {
1613
- return this . randomBackOff ;
1604
+ return getBackoff (). isRandom () ;
1614
1605
}
1615
1606
1607
+ @ Deprecated (since = "3.4.0" , forRemoval = true )
1616
1608
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
+
1618
1674
}
1619
1675
1620
1676
}
0 commit comments