简体   繁体   English

Spring-Kafka vs. Spring-Cloud-Stream(Kafka)

[英]Spring-Kafka vs. Spring-Cloud-Stream (Kafka)

Using Kafka as a messaging system in a microservice architecture what are the benefits of using spring-kafka vs. spring-cloud-stream + spring-cloud-starter-stream-kafka ? 使用Kafka作为微服务架构中的消息传递系统,使用spring-kafka与spring-cloud-stream + spring-cloud-starter-stream-kafka有什么好处?

The spring cloud stream framework supports more messaging systems and has therefore a more modular design. Spring云流框架支持更多的消息传递系统,因此具有更多的模块化设计。 But what about the functionality ? 但功能呢? Is there a gap between the functionality of spring-kafka and spring-cloud-stream + spring-cloud-starter-stream-kafka ? spring-kafka和spring-cloud-stream + spring-cloud-starter-stream-kafka的功能之间是否存在差距? Which API is better designed? 哪个API设计得更好?

Looking forward to read about your opinions 期待阅读您的意见

Spring Cloud Stream with kafka binder rely on Spring-kafka. 带有kafka活页夹的Spring Cloud Stream依赖于Spring-kafka。 So the former has all functionalities supported by later, but the former will be more heavyweight. 所以前者所有功能都得到了后来的支持,但前者会更加重量级。 Below are some points help you make the choice: 以下是一些有助于您做出选择的要点:

  1. If you might change kafka into another message middle-ware in the future, then Spring Cloud stream should be your choice since it hides implementation details of kafka. 如果您将来可能将kafka更改为另一个消息中间件,那么Spring Cloud流应该是您的选择,因为它隐藏了kafka的实现细节。
  2. If you want to integrate other message middle with kafka, then you should go for Spring Cloud stream, since its selling point is to make such integration easy. 如果你想将其他消息中间版与kafka集成,那么你应该选择Spring Cloud流,因为它的卖点是使这种集成变得容易。
  3. If you want to enjoy the simplicity and not accept performance overhead, then choose spring-kafka 如果您想享受简单而不接受性能开销,那么选择spring-kafka
  4. If you plan to migrate to public cloud service, then use spring cloud stream which is part of spring cloud family. 如果您计划迁移到公共云服务,请使用spring cloud stream,它是spring cloud系列的一部分。

Use Spring Cloud Stream when you are creating a system where one channel is used for input does some processing and sends it to one output channel. 在创建系统时使用Spring Cloud Stream ,其中一个通道用于输入进行一些处理并将其发送到一个输出通道。 In other words it is more of an RPC system to replace say RESTful API calls. 换句话说,它更像是一个RPC系统来取代说RESTful API调用。

If you plan to do an event sourcing system, use Spring-Kafka where you can publish and subscribe to the same stream. 如果您打算使用事件采购系统,请使用Spring-Kafka,您可以在其中发布和订阅相同的流。 This is something that Spring Cloud Stream does not allow you do do easily as it disallows the following 这是Spring Cloud Stream不允许您轻松完成的事情,因为它不允许以下内容

public interface EventStream {
    String STREAM = "event_stream";

    @Output(EventStream.STREAM)
    MessageChannel publisher();

    @Input(EventStream.STREAM)
    SubscribableChannel stream();
}

A few things that Spring Cloud Stream helps you avoid doing are: Spring Cloud Stream帮助您避免做的一些事情是:

  • setting up the serializers and deserializers 设置序列化程序和反序列化程序

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

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