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

后端 未结 2 1716
既然无缘
既然无缘 2021-02-03 20:13

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 ?

<
2条回答
  •  太阳男子
    2021-02-03 20:44

    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. In other words it is more of an RPC system to replace say RESTful API calls.

    If you plan to do an event sourcing system, use Spring-Kafka where you can publish and subscribe to the same stream. This is something that Spring Cloud Stream does not allow you do do easily as it disallows the following

    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:

    • setting up the serializers and deserializers

提交回复
热议问题