【发布时间】:2020-05-19 13:09:36
【问题描述】:
我想调用两个具有相同主题配置的不同方法。
假设我有一个 Consumer 项目,它有两个不同的类,具有相同的 kafkalistener 方法。
A 类方法 1:
@KafkaListener(topics = "vijay", groupId = "group_id")
public void consumeMethodOne(String jsonString) {
System.out.println("ConsumerPrice1-->"+jsonString);
}
B 类方法 2:
@KafkaListener(topics = "vijay", groupId = "group_id")
public void consumeMethodTwo(String jsonString) {
System.out.println("ConsumerPrice1-->"+jsonString);
}
还有我的制片人:
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
public void send(String value) {
kafkaTemplate.send("vijay", "This is testing producer");
}
当我运行这个程序时,只有一个方法执行所以如果我想执行这两种方法,因为它们有相同的主题,那么我该如何设置?
【问题讨论】:
-
你的意思是你想消费同一个话题两次?
-
使用相同主题的帖子:stackoverflow.com/questions/59731673/…
-
@Deadpool .. 是的..
-
您的用例是什么?你为什么要这样做?
-
@JosephRajeevMotha : 我有两个不同的
标签: java spring spring-boot apache-kafka