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

Spike on a new API for Kafka Streams support

Open bobby opened this issue 5 years ago • 17 comments

My team ran into some issues when using KafkaStreams with Micronaut on a current project:

  • Returning KStream from factory methods seemed odd and arbitrary (what if my topology only uses KTable or GlobalKTable ?), and the KStream bean itself is never used by the Factory
  • Running multiple KafkaStreams jobs never quite worked right, since the ConfiguredStreamBuilder and KStream weren't named or specified in the KafkaStreams factory method

So we reworked the API a bit, and this new implementation has solved these issues. Now the API looks like:

    @Named("myStream")
    @Singleton
    fun myStream(@Named("my-stream") configuration: KafkaStreamsConfiguration) : ConfiguredStreamBuilder {
        val builder = ConfiguredStreamBuilder(configuration)
        ...
        return builder
    }

If this API looks good to the maintainers, I'll be happy to update the documentation, etc.

bobby avatar May 16 '19 19:05 bobby

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

:x: bobby
:x: tetriscode
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar May 16 '19 19:05 CLAassistant

Test failures seem unrelated and resolved by another PR

graemerocher avatar May 17 '19 07:05 graemerocher

The changes seem ok to me, only think is they are breaking changes. I wonder if there is way to maintain some form of backward's compatibility. Either way we need to alter the version in https://github.com/micronaut-projects/micronaut-kafka/blob/master/gradle.properties#L1 to 1.2.0.BUILD-SNAPSHOT

graemerocher avatar May 17 '19 07:05 graemerocher

@graemerocher If we're backwards-breaking, wouldn't we bump to 2.0.0.BUILD-SNAPSHOT, as per SemVer?

bobby avatar May 18 '19 16:05 bobby

I've rebased with my correct email address in the commit author, to please the CLA bot.

bobby avatar May 18 '19 16:05 bobby

@bobby Would there be any doc updates for your changes?

ctoestreich avatar May 20 '19 18:05 ctoestreich

@ctoestreich Yes, there will need to be doc changes given the new API. This new API will also enable Kafka Streams testing, but I may add that plus testing docs in its own PR.

bobby avatar May 21 '19 13:05 bobby

@bobby could you rebase the changes and provide documentation? We do use semantic versioning so I will need to split out a 1.1.x branch before merging this commit. Thanks.

graemerocher avatar May 21 '19 14:05 graemerocher

@bobby any more thoughts on documentation? I am thinking that may we should just bump the kafka streams module to 2.0 or even split it into a separate repo. That way the core library can continue to evolve. Thoughts?

graemerocher avatar May 27 '19 14:05 graemerocher

Yes, I think at least the kafka-streams module will need to bump to 2.0.0 given the changes, but can probably stay in same repo?

I’m working on the docs now.

Cheers, Bobby

Sent from my iPhone

On May 27, 2019, at 10:22 AM, Graeme Rocher [email protected] wrote:

@bobby any more thoughts on documentation? I am thinking that may we should just bump the kafka streams module to 2.0 or even split it into a separate repo. That way the core library can continue to evolve. Thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bobby avatar May 27 '19 19:05 bobby

While testing an application with several instances of KafkaStreams, we've run up against some difficulties. I'm going to attempt to resolve these difficulties via a few more minor API tweaks in the coming days.

bobby avatar Jun 06 '19 04:06 bobby

@bobby I also ran into this a bit recently. I am available to help with your branch a bit if you want to resurrect this PR. I spent some time during my last PR to add health trying to dissect the KafkaStreamsFactory as I needed stuff there to relate a kstream to the configuration used to build it for metadata on the health endpiont.

ctoestreich avatar May 18 '20 13:05 ctoestreich

@ctoestreich let me know if you plan to contribute this, since we plan to do a release soon. I have updated the module to Kafka 2.5.0 in the meantime

graemerocher avatar May 20 '20 12:05 graemerocher

Spending some time today revisiting @bobby code. @bobby @tetriscode what we’re the remaining open issues?

ctoestreich avatar May 20 '20 12:05 ctoestreich

Hi @bobby @graemerocher @ctoestreich and others, is there any chance to fix this PR and merge it? or to do a serious changes in Micronaut's Kafka Streams configuration/DSL? I'm trying to escape from Spring stack. Micronaut is very promising but the current support for Kafka Streams is far away from being perfect. What I like with Spring approach is that you may easily create several typologies within one project by exposing simple bean bi/functions/consumers using their Spring Cloud Kafka Streams binder (functional style). Except that they offer a configuration hell in yaml files and you loose control over the streams. Recently I've noticed a new library with very promising API/DSL on the market that is trying to simplify Kafka Streams configuration: https://www.azkarrastreams.io/docs/getting-started/ I didn't have a chance to try it, but it seems to introduce a lot of dependencies. I hope you may inspire from that.

rgonciarz avatar Jul 30 '20 20:07 rgonciarz

We would love contributions in this area to advance this PR and make Micronaut with Kafka streams a better experience

graemerocher avatar Jul 30 '20 21:07 graemerocher

@graemerocher I can't promise now. I have a bigger POC project (btw. a major part might be written in Micronaut) I need to finish till autumn, but who knows after that. I'm also involved in a bigger system written from scratch using Kafka Streams mostly. At the moment I may give you a quickly you a feedback regarding documentation, especially KS once. I would add:

  • more examples (e.g. with joins)
  • multiple topologies (with different applicationId)
  • different serialization (example with Avro or protobuf)
  • how to setup security or add tracing
  • health check (e.g. how to ignore false positive related with rebalancing) etc., etc.

rgonciarz avatar Jul 30 '20 21:07 rgonciarz