Dynamic partition improvements in Kafka binder

Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2706

  - Update partition count changes in Kafka dynamically during runtime
  - Checkstyle fixes
  - PartitionHandler changes
  - Improved handling of expression with 'payload' in the logic
  - Removed getter/setter for PartitionHandler and use ReflectionUtils within Test
  - Renamed property to 'dynamicPartitionUpdatesEnabled' and improved documentation (also one line per sentence)
  - Improved/renamed test to use embeddedkafka and really test update behaviour
  - Javadoc
This commit is contained in:
oliverfuehrer
2023-05-09 10:07:57 +02:00
committed by Soby Chacko
parent e19bdd4381
commit 29c3cd7cdd
4 changed files with 141 additions and 4 deletions

View File

@@ -81,6 +81,8 @@ public class ProducerProperties {
private PollerProperties poller;
private boolean dynamicPartitionUpdatesEnabled = false;
public String getBindingName() {
return bindingName;
}
@@ -195,6 +197,24 @@ public class ProducerProperties {
this.poller = poller;
}
/**
* Returns status of property dynamicPartitionUpdatesEnabled.
* @return true if dynamic updates should are enabled otherwise false
*/
public boolean isDynamicPartitionUpdatesEnabled() {
return dynamicPartitionUpdatesEnabled;
}
/**
* A flag which enables/disables partition count updates during runtime. Disabled by default.
* Depends on binder if supported or not.
* Currently only supported by kafka binder (see 'Partitioning with the Kafka Binder' documentation for details)
* @param enabled true if dynamic updates should be enabled otherwise false
*/
public void setDynamicPartitionUpdatesEnabled(boolean enabled) {
this.dynamicPartitionUpdatesEnabled = enabled;
}
static class ExpressionSerializer extends JsonSerializer<Expression> {
@Override