I am Trying to publish messages two different topics from single producer.
here i created two topics:
@Bean
public NewTopic multi1() {
return TopicBuilder.name("multi1").partitions(1).build();
}
@Bean
public NewTopic multi2() {
return TopicBuilder.name("multi2").partitions(1).build();
}
this is how iam sending the messages to two topics:
public void sendingtomultitopic()
{
IntStream.range(0, 100).forEach(i->this.template.send("multi1", "mutli1 data value->"+i));
IntStream.range(0, 100).forEach(i->this.template.send("multi2", "multi2 data value->"+i));
logger.info("sending finished");
}
is above method is correct way to send to multiple topics?
here below iam trying to consume messages
@KafkaListener(topics = {"multi1,multi2"}, groupId = "diffgroupid3")
public void consumingfrommultitopics(String data) {
logger.info(String.format("consumingfromtwotopics -> %s", data));
}
exception iam receiving:
org.apache.kafka.common.errors.InvalidTopicException: Invalid topics: [multi1,multi2]
iam able to the published data in those two topics.
but this consumer is not retrieving any messages, please help me here?