Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Multiple Producer On the same Kafka Topic #59

Closed
sshemirani opened this issue Apr 19, 2022 · 2 comments
Closed

Support Multiple Producer On the same Kafka Topic #59

sshemirani opened this issue Apr 19, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@sshemirani
Copy link

sshemirani commented Apr 19, 2022

The Producers should also include the "oneOf" in the "message" property of the generated Async api file.

Currently adding two producer on the same topic in the AsyncApiDocket configuration, results to one overriding the other and only the last one is included.

Here's the configuration that results in such an issue. You can see that the searchProducer and the retrieveProducer variables have the same topic.

@Bean
 public AsyncApiDocket asyncApiDocket(KafkaProperties kafkaProperties) {
        Info info = Info.builder()
                .version(asyncApiVersion)
                .title("Party Adapter Async API")
                .build();

        Server kafkaServer = Server.builder()
                .protocol("kafka")
                .url(String.join(",", kafkaProperties.getBootstrapServers()))
                .build();

        ProducerData searchProducer = ProducerData.builder()
                .channelName(replyTopic)
                .payloadType(PartySearchResultPayload.class)
                .binding(ImmutableMap.of("kafka", new KafkaOperationBinding()))
                .build();

        ProducerData retrieveProducer = ProducerData.builder()
                .channelName(replyTopic)
                .payloadType(PartyRetrieveResultPayload.class)
                .binding(ImmutableMap.of("kafka", new KafkaOperationBinding()))
                .build();

        return AsyncApiDocket.builder()
                .basePackage(BASE_PACKAGE_SCAN)
                .info(info)
                .producers(List.of(searchProducer, retrieveProducer))
                .server("kafka", kafkaServer)
                .build();
}

In the previous release you supported the @KafkaHandler that results in having "oneOf" property in the generated json. The producer also needs that.

Thank you

@stavshamir
Copy link
Member

Makes a lot of sense and easy to implement. Thanks for the detailed example! I will add this to the next release.

@stavshamir
Copy link
Member

Released in springwolf-kafka-0.5.0. Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants