英文:
Spring Cloud Stream Test Binder does not populate topic header
问题
当从Spring Cloud Stream测试绑定器中消费消息时,以下标头未填充:
kafka_receivedTopic
但当我连接到实际的Kafka代理时,它会填充。
是否有一种方法可以在消费者中获取主题。
我的消费者:
@Bean
public Consumer<Message<PlaneEvent>> planeEventConsumer() {
return event -> {
// do something
};
}
英文:
When a message is consumed from the Spring Cloud Stream test binder, the following header is not populated:
kafka_receivedTopic
But when I connect to an actual kafka broker, it's populated.
Is there a way to get the topic in the consumer.
My consumer:
@Bean
public Consumer<Message<PlaneEvent>> planeEventConsumer() {
return event -> {
// do something
};
}
答案1
得分: 0
测试绑定器确实如此;它不是一个“测试Kafka”绑定器;它是通用的。
通常最好在测试中使用真实的绑定器,带有内置代理,或者使用TestContainers。
英文:
The test binder is exactly that; it is not a "test Kafka" binder; it is generic.
It is generally better to use the real binder for tests, with an embedded broker, or TestContainers.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论