Pushing Router Data to DIstributed Messaging System

别说谁变了你拦得住时间么 提交于 2019-12-11 19:01:22

问题


Query: Making an interface of router as the producer of kafka cluster.

Issue: My router's interface is trying to push the data to the port on which kafka is running. (by default 9092).

Q. 1 But can the kafka broker accept this data without a topic being created ?

Q. 2 Can a kafka consumer pull data without specifying a topic ?

      If yes, How ?

      If not, What is work around this and how can i achieve this ?

1st edit:

I just checked that Kafka broker configs have "auto.create.topics.enable" field. If i set this as true and send some random data on kafka's port without using "kafka-console-producer" command, will the kafka broker accept it?

Thank You.


回答1:


can the kafka broker accept this data without a topic being created

By default Kafka broker is set up in a way that it creates topic if you're trying to push data to it and it does not exists yet. This behaviour is controlled by auto.create.topics.enable parameter (with true/false values).

But broker cannot accept data without topic creation at all. And yes, topic name has to be specified on a producer side.

Can a kafka consumer pull data without specifying a topic

No, it cannot.

If not, What is work around this and how can i achieve this ?

You have to somehow retrieve topic name, for example, by listing all topics through the api and picking proper one, or you can dig directly into zookeeper internals, though I would not recommend you to do that.

I just checked that Kafka broker configs have "auto.create.topics.enable" field. If i set this as true and send some random data on kafka's port without using "kafka-console-producer" command, will the kafka broker accept it?

Of course not. Kafka uses it's own protocol to establish connection between producer and broker, broker and consumer, moreover, those messages are encoded specifically.



来源:https://stackoverflow.com/questions/24269571/pushing-router-data-to-distributed-messaging-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!