From 31ecdb0a1b90edefb7b7b8156ee09573ed1d357e Mon Sep 17 00:00:00 2001 From: Jaakko Malkki Date: Tue, 11 Oct 2022 15:58:46 +0300 Subject: [PATCH] Allow specifying list of topics to subscribe in configuration --- src/main/java/fi/hsl/common/pulsar/PulsarApplication.java | 2 +- src/main/resources/common.conf | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/fi/hsl/common/pulsar/PulsarApplication.java b/src/main/java/fi/hsl/common/pulsar/PulsarApplication.java index d96b9c5..1c53221 100644 --- a/src/main/java/fi/hsl/common/pulsar/PulsarApplication.java +++ b/src/main/java/fi/hsl/common/pulsar/PulsarApplication.java @@ -199,7 +199,7 @@ protected Consumer createConsumer(@NotNull PulsarClient client, @NotNull if (config.getBoolean("pulsar.consumer.multipleTopics")) { if (config.hasPath("pulsar.consumer.topics")) { - List topics = config.getStringList("pulsar.consumer.topics"); + List topics = Arrays.asList(config.getString("pulsar.consumer.topics").split(",")); log.info("Creating Pulsar consumer for topics: [ {} ]", String.join(", ", topics)); builder = builder.topics(topics); } else { diff --git a/src/main/resources/common.conf b/src/main/resources/common.conf index 5c81acf..0460cc4 100644 --- a/src/main/resources/common.conf +++ b/src/main/resources/common.conf @@ -12,6 +12,8 @@ pulsar { #Consume multiple topics: multipleTopics=false multipleTopics=${?PULSAR_CONSUMER_ENABLE_MULTIPLE_TOPICS} + topics="" + topics=${?PULSAR_CONSUMER_TOPICS} topicsPattern="" topicsPattern=${?PULSAR_CONSUMER_MULTIPLE_TOPICS_PATTERN} #Options for type: Exclusive, Shared, Failover