Kafka Streams 在 Golang 中的使用

huangapple go评论88阅读模式
英文:

kafka streams in golang

问题

我正在尝试使用Golang在Go中创建一个Kafka流客户端。根据我所了解,这只有在使用Java客户端时才可能实现。我进行了一些搜索,找到了一些第三方库,但没有找到官方的库。另外,根据我有限的理解,我认为流是对标准消费者的语法糖,这样理解对吗?

英文:

I'm trying to use golang to create a kafka stream client in Go. From what I have seen this is only possible if using a Java Client. I did a bit of searching and found a few other third party libraries but nothing official. Also from my limited understanding I think streams is syntactic sugar over the standard consumers ? is this correct ?

答案1

得分: 1

回答你的这个特定问题,

> 另外根据我有限的理解,我认为流是对标准消费者的语法糖?这个说法正确吗?

在实现异步微服务时,我们可以使用生产者消费者API,但这些API太低级了,它们对于理解如何使用Kafka很有帮助,但如果我们想要实现更复杂的应用程序,它们可能太低级了。此外,当我们开发事件驱动的应用程序时,可能需要实现多阶段处理,即连接多个阶段。在每个阶段,我们将从Kafka读取事件,对其进行处理,并写入输出主题。再次强调,使用生产者和消费者API将需要相当多的工作。而我们可以使用的更高级的解决方案之一就是Kafka StreamsKafka Streams是一个非常灵活的库,它支持无状态流处理,也支持有状态处理。

注意:如果你有选择使用Go以外的语言工作的选项,我强烈推荐使用Java来使用Kafka Streams。只是提一下,我们过去两年一直在使用Java来使用Kafka Streams,并且我们觉得Kafka Streams更像是一个Java库,而不是一个分布式系统。

英文:

To answer your this particular question,
> Also from my limited understanding I think streams is syntactic sugar
> over the standard consumers ? is this correct?

When implementing asynchronous microservices, we could use producer and consumer APIs but these APIs are too low level, they were good to understand how to use Kafka, but if we want to implement more complex applications, they might be too low level. Also, when we develop event‑driven applications, we might need to implement multistage processing when we would connect multiple stages. At each stage, we will read events from Kafka, process them, and write to output topics. Again, using producer and consumer APIs would be quite a lot of work. And one of the more high‑level solutions we can use is called Kafka Streams. Kafka Streams is a very versatile library, it supports stateless stream processing and it also supports stateful processing.

Note: And if you have the option of working with a language other than Go, I would highly recommend working with Java for Kafka Streams. Just to mention here we have been working with Kafka Streams using Java for the last two years and we have felt Kafka Streams is more of a Java library than a distributed system.

答案2

得分: 0

当直接使用标准的Consumer和Producer时,缺乏以下支持:

  • 流转换(聚合等)
  • 本地容错状态(kstreams使用RocksDB)

Goka [https://github.com/lovoo/goka] 是目前一个相对活跃的项目,用于支持Kafka Streams的Golang版本。

英文:

When using standard Consumer and Producer directly, it lacks support for such as the following:

  • stream transformation (aggregation and etc.)
  • fault-tolerant state in local (kstreams uses RocksDB)

Goka [https://github.com/lovoo/goka] is now a relatively active project for Kafka Streams golang support.

huangapple
  • 本文由 发表于 2021年12月13日 12:01:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/70329800.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定