0

How to create multiple EmbeddedKafka, right now i have defined two topics on EmbeddedKafka.

@EmbeddedKafka(
    partitions = 1,
    topics = [Constants.TEST_TOPIC_one, Constants.TEST_TOPIC_two],
    controlledShutdown = false,
    brokerProperties = [
        "offsets.topic.replication.factor=1",
        "transaction.state.log.replication.factor=1",
        "transaction.state.log.min.isr=1"
    ]
)
but i need to have two instance like below,

@EmbeddedKafka(
        partitions = 1,
        topics = [Constants.TEST_TOPIC_one],
        controlledShutdown = false,
        brokerProperties = [
            **"offsets.topic.replication.factor=1",
            "transaction.state.log.replication.factor=1",
            "transaction.state.log.min.isr=1"**
        ]
    )

@EmbeddedKafka(
        partitions = 1,
        topics = [Constants.TEST_TOPIC_two],
        controlledShutdown = false,
        brokerProperties = [
            **"offsets.topic.replication.factor=2",**
            "transaction.state.log.replication.factor=1",
            "transaction.state.log.min.isr=1"
        ]
    )

in the above block i will be changing replication.factor

jcrshankar
  • 1,165
  • 8
  • 25
  • 45

1 Answers1

1

If that the case then, you need to create an EmbeddedKafkaBroker manually, not relying on the annotation processing (and probably not as a bean): https://docs.spring.io/spring-kafka/docs/current/reference/html/#testing

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118