springwolf-core
springwolf-core copied to clipboard
Documentation is not correctly generated when having producer and consumer for the same topic.
Describe the bug
- We have a Spring Boot microservice, let's say it is called "test-service"
- "test-service" has the following consumers: 2.1 ConsumerA -> consumers "topic-a" 2.2 ConsumerB -> consumer "topic-b"
- Now let's say we configure an asyncApiDocket Bean. Everything works fine and I can see both consumers in springwolf ui.
- Now we add ProducerA -> produces events to "topic-a'.
- Now springwolf ui display only consumer for topic-b and producer for topic-a. Seems the consumer for topic-a documentation was overwritted.
Dependencies and versions used
springwolf-kafka version 0.6.1. I tried with 0.7.0 as well.
Code example
@SpringBootApplication(scanBasePackages = {})
public class ExampleApplication {
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
}
}
@Component
@RequiredArgsConstructor
@Slf4j
@KafkaListener(
batch = "true",
topics = "topic-a"
)
public class ConsumerA {
@KafkaHandler
public void consume(Object event) {
}
}
@Component
@RequiredArgsConstructor
@Slf4j
@KafkaListener(
batch = "true",
topics = "topic-b"
)
public class ConsumerB {
@KafkaHandler
public void consume(Object event) {
}
}
@EnableAsyncApi
@Configuration
public class AsyncApiConfigurationTest {
private static final String LISTENERS_SCAN_PACKAGE =
"example.consumer";
@Bean
public AsyncApiDocket asyncApiDocket(
@Value("${service.name}") String appName,
@Value("${service.version}") String appVersion,
@Value("${spring.kafka.bootstrap-servers}") String bootstrapServers) {
Info info = Info.builder()
.version(appVersion)
.title(appName)
.description("description")
.build();
String producerTopicName = "topic-a";
ProducerData preparedDataProducer = ProducerData.builder()
.channelName(producerTopicName)
.operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding()))
.payloadType(FetchUserBalances.class)
.build();
return AsyncApiDocket.builder()
.basePackage(LISTENERS_SCAN_PACKAGE)
.server("kafka", Server.builder().protocol("kafka").url(bootstrapServers).build())
.producer(preparedDataProducer)
.info(info)
.build();
}
Stack trace and error logs No exceptions in log