springwolf / springwolf-core

Automated documentation for event-driven applications built with Spring Boot
https://www.springwolf.dev
Apache License 2.0
244 stars 68 forks source link

[Enhancement request] SpringWolf to be compatible with Reactor Kafka #831

Open KafkaProServerless opened 2 months ago

KafkaProServerless commented 2 months ago

Hello team,

Came into this project from this talk: https://www.youtube.com/watch?v=DylvTW_ia4Y

If nothing else, this project seems to be very cool, very interesting.

We are using Kafka, and want to integrate with SpringWolf.

However, we are not using a regular Spring Kafka, but using reactor kafka https://github.com/reactor/reactor-kafka

Same question as in the talk around minute 33, can this project support reactor kafka?

Thank you

github-actions[bot] commented 2 months ago

Welcome to Springwolf. Thanks a lot for reporting your first issue. Please check out our contributors guide and feel free to join us on discord.

sam0r040 commented 2 months ago

Hi @KafkaProServerless, thanks a lot for your interest in Springwolf and watching the video. Springwolf heavily relies on Spring Framework and therefore we do not plan nor have the capacity to support other frameworks.

KafkaProServerless commented 1 month ago

Hello @sam0r040, thank you for the answer. But reactor kafka is also relying on Spring Framework. It is not like reactor kafka is something that has nothing to do with spring kafka, it is just the reactor version of it.

sam0r040 commented 1 month ago

Hi @KafkaProServerless, if you have Spring ecosystem available, then you can use Springwolf. We can imagine that the following could work for you:

Given the example consumer from ractor-kafka, you can use Springwolfs generic annotations like this:

    @AsyncListener(
            operation = @AsyncOperation(
                    channelName = "kafka-topic-name"
            )
    )
    private void receiveRecord(CountDownLatch latch, @Payload ReceiverRecord<Integer, PayloadDto> record) {
    }

    record PayloadDto(String myProperty) {
    }

We extracted the lambda into a method so that you can make use of the @Payload annotation so that Springwolf can automatically detect payload type.

Don not forget to configure extractable classes for ReceiverRecord to that the payload is extracted correctly from the second generic type: springwolf.payload.extractable-classes.reactor.kafka.receiver.ReceiverRecord=1

See https://www.springwolf.dev/docs/configuration/documenting-consumers#asynclistener for more details.

KafkaProServerless commented 1 month ago

Let me try that!