eventuate-foundation / eventuate-messaging-kafka-quarkus

Other
0 stars 1 forks source link

Quarkus does not support map of properties #1

Open dartartem opened 3 years ago

dartartem commented 3 years ago

Background

eventuate-messaging-kafka allows to define any kafka specific property to consumer/producer.

spring application.properties example:

eventuate.local.kafka.consumer.properties.session.timeout.ms=10000
eventuate.local.kafka.consumer.properties.key.serializer=org.apache.kafka.common.serialization.StringSerializer

properties resolved dynamically. Spring properties example:

@ConfigurationProperties("eventuate.local.kafka.consumer")
public class EventuateKafkaConsumerSpringConfigurationProperties {
  Map<String, String> properties = new HashMap<>();

  public Map<String, String> getProperties() {
    return properties;
  }
}

Why it is important

in case if kafka version is updated and provided new configuration properties, it will be not necessary to update eventuate-messaging-kafka

Problem

According the following issues, quarkus does not support similar behavior:

https://github.com/quarkusio/quarkus/issues/8017 https://github.com/eclipse/microprofile-config/issues/545

Only one way I found to support it, it is write quarkus extension:

https://stackoverflow.com/a/61673372/14879093

I see the following drawbacks:

Proposed solution

Currently I implemented json configuration for kafka properties:

eventuate.local.kafka.consumer.additional-properties={"key.serializer" : "org.apache.kafka.common.serialization.StringSerializer", "session.timeout.ms" : "10000"}

It is simple and not much more inconvenient than property per config.

cer commented 3 years ago

You solution seems reasonable. However, I'd support the existing map for Spring/Micronaut since that works well there.

dartartem commented 3 years ago

Chris,

If you mean that I should use json configuration only for quarkus modules and use existing approach for spring/micronaut, then I did exactly it. If you mean something else, could you please clarify?

cer commented 3 years ago

use json configuration only for quarkus modules and use existing approach for spring/micronaut,

Yes

dartartem commented 3 years ago

Got it. Thank you.