private <T> CompletableFuture<Consumer<T>> singleTopicSubscribeAsync(ConsumerConfigurationData<T> conf, Schema<T> schema, ConsumerInterceptors<T> interceptors) { if (schema instanceof AutoConsumeSchema) { AutoConsumeSchema autoConsumeSchema = (AutoConsumeSchema) schema; return lookup.getSchema(TopicName.get(conf.getSingleTopic())) .thenCompose(schemaInfoOptional -> { if (schemaInfoOptional.isPresent() && schemaInfoOptional.get().getType() == SchemaType.AVRO) { GenericSchema genericSchema = GenericSchema.of(schemaInfoOptional.get()); log.info("Auto detected schema for topic {} : {}", conf.getSingleTopic(), new String(schemaInfoOptional.get().getSchema(), UTF_8)); autoConsumeSchema.setSchema(genericSchema); return doSingleTopicSubscribeAsync(conf, schema, interceptors); } else { return FutureUtil.failedFuture( new PulsarClientException.LookupException("Currently schema detection only works for topics with avro schemas")); } }); } else { return doSingleTopicSubscribeAsync(conf, schema, interceptors); } }
public <T> CompletableFuture<Reader<T>> createReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) { if (schema instanceof AutoConsumeSchema) { AutoConsumeSchema autoConsumeSchema = (AutoConsumeSchema) schema; return lookup.getSchema(TopicName.get(conf.getTopicName())) .thenCompose(schemaInfoOptional -> { if (schemaInfoOptional.isPresent() && schemaInfoOptional.get().getType() == SchemaType.AVRO) { GenericSchema genericSchema = GenericSchema.of(schemaInfoOptional.get()); log.info("Auto detected schema for topic {} : {}", conf.getTopicName(), new String(schemaInfoOptional.get().getSchema(), UTF_8)); autoConsumeSchema.setSchema(genericSchema); return doCreateReaderAsync(conf, schema); } else { return FutureUtil.failedFuture( new PulsarClientException.LookupException("Currently schema detection only works for topics with avro schemas")); } }); } else { return doCreateReaderAsync(conf, schema); } } <T> CompletableFuture<Reader<T>> doCreateReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) {
private <T> CompletableFuture<Consumer<T>> singleTopicSubscribeAsync(ConsumerConfigurationData<T> conf, Schema<T> schema, ConsumerInterceptors<T> interceptors) { if (schema instanceof AutoConsumeSchema) { AutoConsumeSchema autoConsumeSchema = (AutoConsumeSchema) schema; return lookup.getSchema(TopicName.get(conf.getSingleTopic())) .thenCompose(schemaInfoOptional -> { if (schemaInfoOptional.isPresent() && schemaInfoOptional.get().getType() == SchemaType.AVRO) { GenericSchema genericSchema = GenericSchema.of(schemaInfoOptional.get()); log.info("Auto detected schema for topic {} : {}", conf.getSingleTopic(), new String(schemaInfoOptional.get().getSchema(), UTF_8)); autoConsumeSchema.setSchema(genericSchema); return doSingleTopicSubscribeAsync(conf, schema, interceptors); } else { return FutureUtil.failedFuture( new PulsarClientException.LookupException("Currently schema detection only works for topics with avro schemas")); } }); } else { return doSingleTopicSubscribeAsync(conf, schema, interceptors); } }
public <T> CompletableFuture<Reader<T>> createReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) { if (schema instanceof AutoConsumeSchema) { AutoConsumeSchema autoConsumeSchema = (AutoConsumeSchema) schema; return lookup.getSchema(TopicName.get(conf.getTopicName())) .thenCompose(schemaInfoOptional -> { if (schemaInfoOptional.isPresent() && schemaInfoOptional.get().getType() == SchemaType.AVRO) { GenericSchema genericSchema = GenericSchema.of(schemaInfoOptional.get()); log.info("Auto detected schema for topic {} : {}", conf.getTopicName(), new String(schemaInfoOptional.get().getSchema(), UTF_8)); autoConsumeSchema.setSchema(genericSchema); return doCreateReaderAsync(conf, schema); } else { return FutureUtil.failedFuture( new PulsarClientException.LookupException("Currently schema detection only works for topics with avro schemas")); } }); } else { return doCreateReaderAsync(conf, schema); } } <T> CompletableFuture<Reader<T>> doCreateReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) {