|
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;
|
@@ -1644,36 +1645,114 @@ public void setAttempts(int attempts) {
|
1644 | 1645 | this.attempts = attempts;
|
1645 | 1646 | }
|
1646 | 1647 |
|
| 1648 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.delay", since = "3.4.0") |
| 1649 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1647 | 1650 | public Duration getDelay() {
|
1648 |
| - return this.delay; |
| 1651 | + return getBackoff().getDelay(); |
1649 | 1652 | }
|
1650 | 1653 |
|
| 1654 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1651 | 1655 | public void setDelay(Duration delay) {
|
1652 |
| - this.delay = delay; |
| 1656 | + getBackoff().setDelay(delay); |
1653 | 1657 | }
|
1654 | 1658 |
|
| 1659 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.multiplier", |
| 1660 | + since = "3.4.0") |
| 1661 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1655 | 1662 | public double getMultiplier() {
|
1656 |
| - return this.multiplier; |
| 1663 | + return getBackoff().getMultiplier(); |
1657 | 1664 | }
|
1658 | 1665 |
|
| 1666 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1659 | 1667 | public void setMultiplier(double multiplier) {
|
1660 |
| - this.multiplier = multiplier; |
| 1668 | + getBackoff().setMultiplier(multiplier); |
1661 | 1669 | }
|
1662 | 1670 |
|
| 1671 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.maxDelay", since = "3.4.0") |
| 1672 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1663 | 1673 | public Duration getMaxDelay() {
|
1664 |
| - return this.maxDelay; |
| 1674 | + return getBackoff().getMaxDelay(); |
1665 | 1675 | }
|
1666 | 1676 |
|
| 1677 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1667 | 1678 | public void setMaxDelay(Duration maxDelay) {
|
1668 |
| - this.maxDelay = maxDelay; |
| 1679 | + getBackoff().setMaxDelay(maxDelay); |
1669 | 1680 | }
|
1670 | 1681 |
|
| 1682 | + @DeprecatedConfigurationProperty(replacement = "spring.kafka.retry.topic.backoff.randomBackOff", |
| 1683 | + since = "3.4.0") |
| 1684 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1671 | 1685 | public boolean isRandomBackOff() {
|
1672 |
| - return this.randomBackOff; |
| 1686 | + return getBackoff().isRandom(); |
1673 | 1687 | }
|
1674 | 1688 |
|
| 1689 | + @Deprecated(since = "3.4.0", forRemoval = true) |
1675 | 1690 | public void setRandomBackOff(boolean randomBackOff) {
|
1676 |
| - this.randomBackOff = randomBackOff; |
| 1691 | + getBackoff().setRandom(randomBackOff); |
| 1692 | + } |
| 1693 | + |
| 1694 | + private final Backoff backoff = new Backoff(); |
| 1695 | + |
| 1696 | + public Backoff getBackoff() { |
| 1697 | + return this.backoff; |
| 1698 | + } |
| 1699 | + |
| 1700 | + public static class Backoff { |
| 1701 | + |
| 1702 | + /** |
| 1703 | + * Canonical backoff period. Used as an initial value in the exponential |
| 1704 | + * case, and as a minimum value in the uniform case. |
| 1705 | + */ |
| 1706 | + private Duration delay = Duration.ofSeconds(1); |
| 1707 | + |
| 1708 | + /** |
| 1709 | + * Multiplier to use for generating the next backoff delay. |
| 1710 | + */ |
| 1711 | + private double multiplier = 0.0; |
| 1712 | + |
| 1713 | + /** |
| 1714 | + * Maximum wait between retries. If less than the delay then the default |
| 1715 | + * of 30 seconds is applied. |
| 1716 | + */ |
| 1717 | + private Duration maxDelay = Duration.ZERO; |
| 1718 | + |
| 1719 | + /** |
| 1720 | + * Whether to have the backoff delays. |
| 1721 | + */ |
| 1722 | + private boolean random = false; |
| 1723 | + |
| 1724 | + public Duration getDelay() { |
| 1725 | + return this.delay; |
| 1726 | + } |
| 1727 | + |
| 1728 | + public void setDelay(Duration delay) { |
| 1729 | + this.delay = delay; |
| 1730 | + } |
| 1731 | + |
| 1732 | + public double getMultiplier() { |
| 1733 | + return this.multiplier; |
| 1734 | + } |
| 1735 | + |
| 1736 | + public void setMultiplier(double multiplier) { |
| 1737 | + this.multiplier = multiplier; |
| 1738 | + } |
| 1739 | + |
| 1740 | + public Duration getMaxDelay() { |
| 1741 | + return this.maxDelay; |
| 1742 | + } |
| 1743 | + |
| 1744 | + public void setMaxDelay(Duration maxDelay) { |
| 1745 | + this.maxDelay = maxDelay; |
| 1746 | + } |
| 1747 | + |
| 1748 | + public boolean isRandom() { |
| 1749 | + return this.random; |
| 1750 | + } |
| 1751 | + |
| 1752 | + public void setRandom(boolean random) { |
| 1753 | + this.random = random; |
| 1754 | + } |
| 1755 | + |
1677 | 1756 | }
|
1678 | 1757 |
|
1679 | 1758 | }
|
|
0 commit comments