use of org.apache.pulsar.client.impl.conf.ConsumerConfigurationData in project incubator-pulsar by apache.
the class PulsarClientImpl method patternTopicSubscribeAsync.
private <T> CompletableFuture<Consumer<T>> patternTopicSubscribeAsync(ConsumerConfigurationData<T> conf, Schema<T> schema) {
String regex = conf.getTopicsPattern().pattern();
TopicName destination = TopicName.get(regex);
NamespaceName namespaceName = destination.getNamespaceObject();
CompletableFuture<Consumer<T>> consumerSubscribedFuture = new CompletableFuture<>();
lookup.getTopicsUnderNamespace(namespaceName).thenAccept(topics -> {
if (log.isDebugEnabled()) {
log.debug("Get topics under namespace {}, topics.size: {}", namespaceName.toString(), topics.size());
topics.forEach(topicName -> log.debug("Get topics under namespace {}, topic: {}", namespaceName.toString(), topicName));
}
List<String> topicsList = topicsPatternFilter(topics, conf.getTopicsPattern());
conf.getTopicNames().addAll(topicsList);
ConsumerBase<T> consumer = new PatternTopicsConsumerImpl<>(conf.getTopicsPattern(), PulsarClientImpl.this, conf, externalExecutorProvider.getExecutor(), consumerSubscribedFuture, schema);
synchronized (consumers) {
consumers.put(consumer, Boolean.TRUE);
}
}).exceptionally(ex -> {
log.warn("[{}] Failed to get topics under namespace", namespaceName);
consumerSubscribedFuture.completeExceptionally(ex);
return null;
});
return consumerSubscribedFuture;
}
use of org.apache.pulsar.client.impl.conf.ConsumerConfigurationData in project incubator-pulsar by apache.
the class ConsumerConfigurationTest method testJsonIgnore.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testJsonIgnore() throws Exception {
ConsumerConfigurationData<?> conf = new ConsumerConfigurationData<>();
conf.setConsumerEventListener(new ConsumerEventListener() {
@Override
public void becameActive(Consumer<?> consumer, int partitionId) {
}
@Override
public void becameInactive(Consumer<?> consumer, int partitionId) {
}
});
conf.setMessageListener((MessageListener) (consumer, msg) -> {
});
conf.setCryptoKeyReader(mock(CryptoKeyReader.class));
ObjectMapper m = new ObjectMapper();
m.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
ObjectWriter w = m.writerWithDefaultPrettyPrinter();
String confAsString = w.writeValueAsString(conf);
log.info("conf : {}", confAsString);
assertFalse(confAsString.contains("messageListener"));
assertFalse(confAsString.contains("consumerEventListener"));
assertFalse(confAsString.contains("cryptoKeyReader"));
}
Aggregations