|
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;
|
@@ -1585,36 +1586,114 @@ public void setAttempts(int attempts) {
|
1585 | 1586 | this.attempts = attempts;
|
1586 | 1587 | }
|
1587 | 1588 |
|
| 1589 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.delay", since = "3.4.0") |
| 1590 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1588 | 1591 | public Duration getDelay() {
|
1589 |
| - return this.delay; |
| 1592 | + return getBackoff().getDelay(); |
1590 | 1593 | }
|
1591 | 1594 |
|
| 1595 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1592 | 1596 | public void setDelay(Duration delay) {
|
1593 |
| - this.delay = delay; |
| 1597 | + getBackoff().setDelay(delay); |
1594 | 1598 | }
|
1595 | 1599 |
|
| 1600 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.multiplier", |
| 1601 | + since = "3.4.0") |
| 1602 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1596 | 1603 | public double getMultiplier() {
|
1597 |
| - return this.multiplier; |
| 1604 | + return getBackoff().getMultiplier(); |
1598 | 1605 | }
|
1599 | 1606 |
|
| 1607 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1600 | 1608 | public void setMultiplier(double multiplier) {
|
1601 |
| - this.multiplier = multiplier; |
| 1609 | + getBackoff().setMultiplier(multiplier); |
1602 | 1610 | }
|
1603 | 1611 |
|
| 1612 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.maxDelay", since = "3.4.0") |
| 1613 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1604 | 1614 | public Duration getMaxDelay() {
|
1605 |
| - return this.maxDelay; |
| 1615 | + return getBackoff().getMaxDelay(); |
1606 | 1616 | }
|
1607 | 1617 |
|
| 1618 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1608 | 1619 | public void setMaxDelay(Duration maxDelay) {
|
1609 |
| - this.maxDelay = maxDelay; |
| 1620 | + getBackoff().setMaxDelay(maxDelay); |
1610 | 1621 | }
|
1611 | 1622 |
|
| 1623 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.random", |
| 1624 | + since = "3.4.0") |
| 1625 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1612 | 1626 | public boolean isRandomBackOff() {
|
1613 |
| - return this.randomBackOff; |
| 1627 | + return getBackoff().isRandom(); |
1614 | 1628 | }
|
1615 | 1629 |
|
| 1630 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1616 | 1631 | public void setRandomBackOff(boolean randomBackOff) {
|
1617 |
| - this.randomBackOff = randomBackOff; |
| 1632 | + getBackoff().setRandom(randomBackOff); |
| 1633 | + } |
| 1634 | + |
| 1635 | + private final Backoff backoff = new Backoff(); |
| 1636 | + |
| 1637 | + public Backoff getBackoff() { |
| 1638 | + return this.backoff; |
| 1639 | + } |
| 1640 | + |
| 1641 | + public static class Backoff { |
| 1642 | + |
| 1643 | + /** |
| 1644 | + * Canonical backoff period. Used as an initial value in the exponential |
| 1645 | + * case, and as a minimum value in the uniform case. |
| 1646 | + */ |
| 1647 | + private Duration delay = Duration.ofSeconds(1); |
| 1648 | + |
| 1649 | + /** |
| 1650 | + * Multiplier to use for generating the next backoff delay. |
| 1651 | + */ |
| 1652 | + private double multiplier = 0.0; |
| 1653 | + |
| 1654 | + /** |
| 1655 | + * Maximum wait between retries. If less than the delay then the default |
| 1656 | + * of 30 seconds is applied. |
| 1657 | + */ |
| 1658 | + private Duration maxDelay = Duration.ZERO; |
| 1659 | + |
| 1660 | + /** |
| 1661 | + * Whether to have the backoff delays. |
| 1662 | + */ |
| 1663 | + private boolean random = false; |
| 1664 | + |
| 1665 | + public Duration getDelay() { |
| 1666 | + return this.delay; |
| 1667 | + } |
| 1668 | + |
| 1669 | + public void setDelay(Duration delay) { |
| 1670 | + this.delay = delay; |
| 1671 | + } |
| 1672 | + |
| 1673 | + public double getMultiplier() { |
| 1674 | + return this.multiplier; |
| 1675 | + } |
| 1676 | + |
| 1677 | + public void setMultiplier(double multiplier) { |
| 1678 | + this.multiplier = multiplier; |
| 1679 | + } |
| 1680 | + |
| 1681 | + public Duration getMaxDelay() { |
| 1682 | + return this.maxDelay; |
| 1683 | + } |
| 1684 | + |
| 1685 | + public void setMaxDelay(Duration maxDelay) { |
| 1686 | + this.maxDelay = maxDelay; |
| 1687 | + } |
| 1688 | + |
| 1689 | + public boolean isRandom() { |
| 1690 | + return this.random; |
| 1691 | + } |
| 1692 | + |
| 1693 | + public void setRandom(boolean random) { |
| 1694 | + this.random = random; |
| 1695 | + } |
| 1696 | + |
1618 | 1697 | }
|
1619 | 1698 |
|
1620 | 1699 | }
|
|
0 commit comments