Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract producer configuration with empty properties #557

Closed
ices1231 opened this issue May 21, 2020 · 2 comments · Fixed by #558
Closed

Extract producer configuration with empty properties #557

ices1231 opened this issue May 21, 2020 · 2 comments · Fixed by #558
Milestone

Comments

@ices1231
Copy link
Contributor

ices1231 commented May 21, 2020

I have a problem with Producer configuration with optional empty properties. I want to configure security, but disable it in dev profile.

Background

application.yml

mp:
  messaging:
    outgoing:
      test-name:
        connector: smallrye-kafka
        bootstrap:
          servers: localhost:9092
        sasl:
          jaas:
            config: org.apache.kafka.common.security.scram.ScramLoginModule required username=admin password=admin;
          mechanism: SCRAM-SHA-512
        security:
          protocol: SASL_PLAINTEXT
        key:
          serializer: org.apache.kafka.common.serialization.StringSerializer
        value:
          serializer: org.apache.kafka.common.serialization.StringSerializer


"%dev":
   mp:
    messaging:
      outgoing:
      	test-name:
          sasl:
            jaas:
              config: ""
            mechanism: ""
          security:
            protocol: PLAINTEXT

According to eclipse/microprofile-config#446 all is correct I got

Caused by: java.util.NoSuchElementException: Cannot find attribute sasl.mechanism for channel test-name. Has been tried: mp.messaging.outgoing.test-name.sasl.mechanism and mp.messaging.connector.smallrye-kafka.sa
sl.mechanism
at io.smallrye.reactive.messaging.impl.ConnectorConfig.getValue(ConnectorConfig.java:72)
at io.smallrye.reactive.messaging.kafka.impl.JsonHelper.asJsonObject(JsonHelper.java:14)
at io.smallrye.reactive.messaging.kafka.impl.KafkaSink.extractProducerConfiguration(KafkaSink.java:131)
at io.smallrye.reactive.messaging.kafka.impl.KafkaSink.(KafkaSink.java:40)
at io.smallrye.reactive.messaging.kafka.KafkaConnector.getSubscriberBuilder(KafkaConnector.java:86)

Alternative

It is hard to make security properties optional.
Can you change JsonHelper.java, as you did it here default-configuration

config.getValue()  -> config.getOptionalValue()

Thank you in advance

@cescoffier
Copy link
Contributor

That sounds reasonable.

Can you open a PR?

@cescoffier
Copy link
Contributor

Closed #558

@cescoffier cescoffier added this to the 2.1.0 milestone May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants