Start United States USA — software Spring Cloud Stream With Kafka

Spring Cloud Stream With Kafka

139
0
TEILEN

There are quite many binder implementations like e.g Kafka, RabbitMQ, AWS SNS, AWS SQS, etc. Today we would be using the Kafka Binder to communicate with Kafka.
Join the DZone community and get the full member experience. Spring Cloud Stream, is a mechanism by which you can decouple the implementation of your producers and consumers from the type of messaging infrastructure you want to use. This allows us to keep our consumers and producers to be broker agnostic and we can easily switch to a different kind of broker by changing the binder implementation. There are quite many binder implementations like e.g Kafka, RabbitMQ, AWS SNS, AWS SQS, etc. You can find a list of available binder implementations here. Today we would be using the Kafka Binder to communicate with Kafka. Let’s go to https://start.spring.io and create an application with the spring cloud streams dependency. Once you generate the project, You will have to add the Kafka Binder dependency as follows: Now, to create a producer and consumer we only need to create beans with a supplier and a consumer as below: That’s all. You just created a producer and a consumer. Now, this is a functional programming way to create a producer and a consumer to send and receive messages. Now, let’s look at how to configure this to send and receive messages to and from the right destination.

Continue reading...