【发布时间】:2019-01-11 00:24:06
【问题描述】:
我想对我的 kafka 流主题进行交互式查询。
目前我可以将 avro 序列化的 json 对象发送到我的主题并使用 avro 反序列化器再次读取它们。 我在这种情况下使用普通的 MessageChannel Binder,这可以按预期工作。
现在我想使用 kafka 流绑定器,但我无法让它工作。也许有人可以帮助我。
我的配置:
spring:
cloud:
bus:
enabled: true
stream:
schemaRegistryClient.endpoint: http://192.168.99.100:8081
bindings:
segments-in:
destination: segments
contentType: application/vnd.segments-value.v1+avro
segments-all:
destination: segments
group: segments-all
consumer:
headerMode: raw
useNativeDecoding: true
kafka:
binder:
zkNodes: 192.168.99.100:2181
brokers: 192.168.99.100:32768
streams:
bindings:
segments-all:
consumer:
keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde
valueSerde: io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde
Kafka 配置类:
@Configuration
public class KafkaConfiguration {
@Bean
public MessageConverter classificationMessageConverter() {
AvroSchemaMessageConverter converter = new AvroSchemaMessageConverter();
converter.setSchema(Segment.SCHEMA$);
return converter;
}
}
架构配置
@Configuration
public class SchemaRegistryConfiguration {
@Bean
public SchemaRegistryClient schemaRegistryClient(@Value("${spring.cloud.stream.schemaRegistryClient.endpoint}") final String endpoint) {
ConfluentSchemaRegistryClient client = new ConfluentSchemaRegistryClient();
client.setEndpoint(endpoint);
return client;
}
}
现在是我的界面
public interface Channels {
String EVENTS = "segments-in";
String ALLSEGMENTS = "segments-all";
@Input(Channels.EVENTS)
SubscribableChannel events();
@Input(Channels.ALLSEGMENTS)
KTable<?, ?> segmentsIn();
}
我总是收到以下错误(警告消息),但只有当我打开第二个称为segmentsIn() 的通道时。
org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-3] Connection to node -1 could not be established. Broker may not be available.
使用 SubscribableChannel (segments-in) 一切正常,我在这里做错了什么?我怎样才能让频道片段全部与 kafka 流 api 一起使用?
【问题讨论】:
标签: spring apache-kafka avro spring-cloud-stream spring-kafka