0

如何创建多个 EmbeddedKafka,现在我在 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"
        ]
    )

在上面的块中,我将更改 replication.factor

4

1 回答 1

1

如果是这种情况,您需要EmbeddedKafkaBroker手动创建一个,而不是依赖注释处理(并且可能不是作为 bean):https ://docs.spring.io/spring-kafka/docs/current/reference/html/ #测试

于 2021-12-01T14:20:38.220 回答