michelin / kstreamplify

Kstreamplify is a Java library that brings new features on top of Kafka Streams.
Apache License 2.0
92 stars 15 forks source link

KafkaStreamsExecutionContext could expose all properties instead of only the ones under kafka.properties #198

Open SouquieresAdam opened 4 months ago

SouquieresAdam commented 4 months ago

Problem

KStreamplify reads all configurations from the Spring Boot context and exposes those under the kafka.properties prefix in a static global object, KafkaStreamsExecutionContext.

protected void initProperties() { properties = PropertiesUtils.loadProperties(); serverPort = (Integer) properties.get(SERVER_PORT_PROPERTY); kafkaProperties = PropertiesUtils.loadKafkaProperties(properties); KafkaStreamsExecutionContext.registerProperties(kafkaProperties); }

Suggestion

I would like to be able to access all my properties through this object to manage some business or technical aspects that are not directly related to Kafka from my external configuration. Typically, a Kafka Streams application developed with KStreamplify uses Processor or Transformer classes, which are not directly managed by the Spring Application Context.

Alternatives Considered

Possible alternatives for implementation include:

loicgreffier commented 4 months ago

@SouquieresAdam,

Good issue,

I have considered something like:

But this would break the previous version as users would have to move from getProperties() to getKafkaProperties() and would have to look for properties either on kafkaProperties or applicationProperties.

kafka.properties needs to be kept isolated to:

I think the option 2 would just offer the simplest approach: