简体   繁体   English

如何在网页中发送kafka消息

[英]How to send kafka message in webpage

I have a web page which needs send kafka message to a topic. 我有一个网页,需要向主题发送kafka消息。 The web is using vuejs. 网络正在使用vuejs。 And I tried using npm "kafka-node" and "kafkajs", they both have errors when establish kafka connection. 我尝试使用npm“ kafka-node”和“ kafkajs”,在建立kafka连接时它们都出错。 Maybe they are all server side npm? 也许它们都是服务器端的npm?

Is there any js package that supports webpage to act like kafka producer. 是否有任何支持网页的js软件包像kafka生产者一样运行。 I don't want to set up other intermedia servers (like kafka http proxy). 我不想设置其他中间服务器(例如kafka http代理)。 I want the webpage directly send messages to topic. 我希望网页直接向主题发送消息。 Is it workable? 可行吗?

Kafka isn't really designed to be publicly accessible in this way, so I would suggest that you use something like the below which allows you to deploy a RESTful interface to your kafka cluster. Kafka并非真正设计为可通过这种方式公开访问,因此,我建议您使用类似以下的内容,以允许您将RESTful接口部署到您的kafka集群。 That way you can just POST messages directly to your kafka topic. 这样,你可以只POST直接邮件到您的卡夫卡的话题。

https://github.com/confluentinc/kafka-rest https://github.com/confluentinc/kafka-rest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM