Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Apache kafka with Spring mvc ? Is it possible?

I am beginner with apache kafka and trying to learn confluent - kafka - rest - utils, however I am confusing with how can I use it.

During search I found this documentation https://spring.io/blog/2015/04/15/using-apache-kafka-for-integration-and-data-processing-pipelines-with-spring

It is very good documentation but It doesn't help me to learn rest-utils.

The git code of confluent kafka rest utils is

https://github.com/confluentinc/kafka-rest is demonstrate how to use rest kafka. But I want to know the exact procedure to be more aware about it. with some simple explanation. Can anyone suggest me some links with how I use rest client. Please guide me towards this.

It might be a silly question but I don't have other option to learn.

thanks in advance.

like image 417
Jimmy Avatar asked May 29 '15 07:05

Jimmy


People also ask

Does Kafka use Spring Framework?

The Spring for Apache Kafka (spring-kafka) project applies core Spring concepts to the development of Kafka-based messaging solutions. It provides a "template" as a high-level abstraction for sending messages. It also provides support for Message-driven POJOs with @KafkaListener annotations and a "listener container".

How does Kafka integrate with Spring boot application?

In this chapter, we are going to see how to implement the Apache Kafka in Spring Boot application. First, we need to add the Spring Kafka dependency in our build configuration file. Maven users can add the following dependency in the pom. xml file.

What is Spring integration Kafka?

The Spring Integration for Apache Kafka extension project provides inbound and outbound channel adapters and gateways for Apache Kafka. Apache Kafka is a distributed publish-subscribe messaging system that is designed for high throughput (terabytes of data) and low latency (milliseconds).

Does Kafka support REST API?

The Kafka REST Proxy is a RESTful web API that allows your application to send and receive messages using HTTP rather than TCP. It can be used to produce data to and consume data from Kafka or for executing queries on cluster configuration.


1 Answers

First try to create a REST service using spring MVC keeping kafka stuff aside.

Once you are able run a 'hello world' kind of REST service, then pick Kafka Docs.

Refer documents on how to create a kafka cluster, and run default console consumer and producer programs to check your cluster.

Now, write a main java program and create a kafka producer using Kafka Clients API. Refer its docs. Make sure that messages sent through main program are reaching to the consumer.

Now, inject the content of this main program in rest service, so that messages passed in request body are now passed to kafka cluster and are readable by consumer.

Hope it helps.

like image 75
Deepak Bansal Avatar answered Sep 23 '22 00:09

Deepak Bansal