简体   繁体   中英

Subscribing a rest api to kafka events

I recently started working on Kafka for a project of mine.

I am trying to figure out how can I subscribe a rest API to a Kafka event rather than running a consumer which keeps on listening to the topic.

I came across Kafka connect, but not able to figure out exactly how to achieve the same.

Details: I am running a spring-boot project as a producer which uses KafkaTemplate provided by spring to publish the message. Also, the consumer is a Spring Boot project which exposes rest APIs.

There is no other way than to use the Kafka consumer library to have data come from Kafka. Kafka Connect would do the same.

A RESTful service is stateless. Having a consumer is more stateful (offset maintenance, for example).

If you want streaming events in general, maybe you could look into WebSockets or gRPC instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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