0

I'm configuring spring boot kafka streams in application.yaml. I need to configure properties of the output topics:

producer:
  topic.properties:
    cleanup.policy: compact
    retention.ms: 604800000

Because I have the same configuration across the whole file I want to make single point where to define values:

my:
 policy: compact
 retention: 604800000
producer:
  topic.properties:
    cleanup.policy: ${my.policy}
    retention.ms: ${my.retention}

But the topic.properties is just generic map passed to underlying kafka library. To make the configuration more flexible I would like to reference the my section from the producer.topic.properties. So when new kafka property is added then only my section is updated.

I tried:

producer:
  topic.properties: ${my}

But this doesn't work - ${my} is replaced by my.toString() and configuration fails on getting String where Map is expected.

I'm looking for some section placeholder. For example in OpenAPI Spec you can do something similar to:

my:
 policy: compact
 retention: 604800000
producer:
  topic.properties:
     $ref: '/my'

I know basic YAML doesn't support references. But is there something in spring-boot allowing to reference other config sections?

Masáč
  • 163
  • 1
  • 5

1 Answers1

0

You can reference other properties, but one at a time:

my:
 policy: compact
 retention: 604800000
producer:
  topic.properties:
     policy: ${my.policy}
     retention: ${my.retention}
Michael
  • 556
  • 3
  • 12