spring-kafka icon indicating copy to clipboard operation
spring-kafka copied to clipboard

Support for KafkaProxy for @KafkaListener

Open nnordrum opened this issue 6 years ago • 10 comments

I think it would be very helpful to have support for swapping out the "backend" of @KafkaListener to support connecting via the Kafka RESTProxy instead of the normal kafka-client.

I realize you may not get 100% support, but I see MessageListenerContainer already has some UnsupportedOperationException defaulted methods, and even just very simple consuming/producing would be a nice addition.

nnordrum avatar Mar 19 '18 17:03 nnordrum

Sounds like a separate implementation and not a mix of concerns for the @KafkaListener.

May you, please, share as much info on the matter as possible? Maybe some PoC would be really great.

I see that RESTProxy is a part of Confluent Platform: https://docs.confluent.io/current/kafka-rest/docs/index.html. We don't have any integration with that one though...

artembilan avatar Mar 19 '18 17:03 artembilan

The reason it wouldn't necessarily be a mix of concerns, IMO, is that @KafkaListener could/would/should be like PreparedStatement, or JdbcTemplate, where my code doesn't care if I'm pointing at the RESTProxy or using a KafkaClient.

As it stands right now, if I develop a number of @KafkaListeners and then somebody in security says "oh, we just decided to restrict kafka--please go through the services gateway", I have a ton of work to do. If I could just include spring-kafka-rest (separate, but related), configure a RestTemplate, and bob's your uncle.

Since they are ultimately exposing the same thing via two different mechanisms, it seems like it shouldn't be that painful to do... just implement some new factories and impl classes. I'm not that familiar with the way it's been abstracted though, so it could be much worse than in #IvoryTower.

nnordrum avatar Mar 19 '18 23:03 nnordrum

Sounds like it would just need a rest-based implementation of the KafkaMessageListenerContainer and a corresponding subclass of AbstractKafkaListenerContainerFactory to wire it into the kafka listeners.

Contributions are welcome.

garyrussell avatar Mar 20 '18 16:03 garyrussell

I'd be glad to--I was just trying to get some guidance. This sounds like a good transatlantic task :) I'll try and get something next week.

Should I just do it in spring-kafka/src? or should I add (at least for the sake of reviewing) a spring-kafka-proxy/src?

nnordrum avatar Mar 20 '18 19:03 nnordrum

I don't think a new subproject is necessary; it will share a bunch of stuff from s-k, including the abstract container. Perhaps a new package o.s.k.rest.listener. With, perhaps a rest-based KafkaTemplate in o.s.k.rest.producer or similar.

This will probably have to be a 2.2 feature since we'll need changes in ConcurrentMessageListenerContainer to support a collection of abstract containers instead of

List<KafkaMessageListenerContainer<K, V>> containers;

We'll probably fork off a 2.1.x branch after we release 2.1.5 next week and master can become the 2.2 dev branch.

garyrussell avatar Mar 20 '18 19:03 garyrussell

sounds like a plan.

nnordrum avatar Mar 20 '18 19:03 nnordrum

Any news regarding this topic? i think many will be interested in this feature :)

victorgetz avatar Aug 14 '19 17:08 victorgetz

We're still open to contributions, but it's unlikely to make it into 2.3; the release candidate is due in a couple of weeks.

garyrussell avatar Aug 14 '19 18:08 garyrussell

Any updates regarding this issue ? we are interested as well to use KafkaProxy with Kafka-Spring. Thanks.

swisair1 avatar Apr 25 '21 10:04 swisair1

There are no updates; the project itself does not have plans to implement it; but we will consider a community contribution.

garyrussell avatar Apr 26 '21 14:04 garyrussell