Kafka模板和kafka生产者之间有什么区别? [英] What is the difference between Kafka Template and kafka producer?

查看:441
本文介绍了Kafka模板和kafka生产者之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我所见,Kafka模板内部使用了Kafka生产者.我只想知道确切的区别是什么.此外,与Kafka生产者相比,我在Kafka模板中发现了许多send()方法.
请帮我.如果有人知道更多.

As I have seen the Kafka template internally used Kafka producer. I just want to know what is the exact difference. Also, I found many send() methods available in the Kafka template as compared to Kafka producer.
Please help me with it. If anyone knows more.

推荐答案

生产者是模式,而KafkaTemplate包装了Producer实例,并提供了将消息发送到Kafka主题的便捷方法.()

The producer is the pattern, while the KafkaTemplate wraps a Producer instance and provides convenience methods for sending messages to Kafka topics. (source)

Kafka 生产者是在Apache Kafka中定义的. KafkaTemplate 是Spring的实现它(尽管它没有直接实现Producer),因此它提供了更多的方法供您使用.因此,您可以使用KafkaTemplate入门,也可以通过自己实现Producer来实现自己的解决方案.

The Kafka Producer is defined in Apache Kafka. The KafkaTemplate is Spring's implementation of it (although it does not implement Producer directly) and so it provides more methods for you to use. So you can use KafkaTemplate to get started or implement your own solution through implementing the Producer yourself.

这篇关于Kafka模板和kafka生产者之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆