Remove duplicate KafkaStreams topology endpoint
Resolves https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/895
This commit is contained in:
@@ -1468,7 +1468,7 @@ Kafka Streams binder provides the following actuator endpoints for retrieving th
|
||||
|
||||
`/actuator/kafkastreamstopology`
|
||||
|
||||
`/actuator/kafkastreamstopology/<applicaiton-id of the processor>`
|
||||
`/actuator/kafkastreamstopology/<application-id of the processor>`
|
||||
|
||||
You need to include the actuator and web dependencies from Spring Boot to access these endpoints.
|
||||
Further, you also need to add `kafkastreamstopology` to `management.endpoints.web.exposure.include` property.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.stream.binder.kafka.streams.endpoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
@@ -46,13 +47,14 @@ public class KafkaStreamsTopologyEndpoint {
|
||||
}
|
||||
|
||||
@ReadOperation
|
||||
public String kafkaStreamsTopology() {
|
||||
public List<String> kafkaStreamsTopologies() {
|
||||
final List<StreamsBuilderFactoryBean> streamsBuilderFactoryBeans = this.kafkaStreamsRegistry.streamsBuilderFactoryBeans();
|
||||
final StringBuilder topologyDescription = new StringBuilder();
|
||||
final List<String> descs = new ArrayList<>();
|
||||
streamsBuilderFactoryBeans.stream()
|
||||
.forEach(streamsBuilderFactoryBean ->
|
||||
topologyDescription.append(streamsBuilderFactoryBean.getTopology().describe().toString()));
|
||||
return topologyDescription.toString();
|
||||
descs.add(streamsBuilderFactoryBean.getTopology().describe().toString()));
|
||||
return descs;
|
||||
}
|
||||
|
||||
@ReadOperation
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.stream.binder.kafka.streams.function;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -112,7 +113,8 @@ public class KafkaStreamsBinderWordCountFunctionTests {
|
||||
//Testing topology endpoint
|
||||
final KafkaStreamsRegistry kafkaStreamsRegistry = context.getBean(KafkaStreamsRegistry.class);
|
||||
final KafkaStreamsTopologyEndpoint kafkaStreamsTopologyEndpoint = new KafkaStreamsTopologyEndpoint(kafkaStreamsRegistry);
|
||||
final String topology1 = kafkaStreamsTopologyEndpoint.kafkaStreamsTopology();
|
||||
final List<String> topologies = kafkaStreamsTopologyEndpoint.kafkaStreamsTopologies();
|
||||
final String topology1 = topologies.get(0);
|
||||
final String topology2 = kafkaStreamsTopologyEndpoint.kafkaStreamsTopology("testKstreamWordCountFunction");
|
||||
assertThat(topology1).isNotEmpty();
|
||||
assertThat(topology1).isEqualTo(topology2);
|
||||
|
||||
Reference in New Issue
Block a user