@@ -31,6 +31,7 @@ static const std::string CFG_TOPICS_PATTERN = "topicsPattern";
3131static const std::string CFG_SUBSCRIPTION = " subscription" ;
3232static const std::string CFG_SUBSCRIPTION_TYPE = " subscriptionType" ;
3333static const std::string CFG_INIT_POSITION = " subscriptionInitialPosition" ;
34+ static const std::string CFG_REGEX_SUBSCRIPTION_MODE = " regexSubscriptionMode" ;
3435static const std::string CFG_ACK_TIMEOUT = " ackTimeoutMs" ;
3536static const std::string CFG_NACK_REDELIVER_TIMEOUT = " nAckRedeliverTimeoutMs" ;
3637static const std::string CFG_RECV_QUEUE = " receiverQueueSize" ;
@@ -53,6 +54,11 @@ static const std::map<std::string, pulsar_consumer_type> SUBSCRIPTION_TYPE = {
5354 {" KeyShared" , pulsar_ConsumerKeyShared},
5455 {" Failover" , pulsar_ConsumerFailover}};
5556
57+ static const std::map<std::string, pulsar_consumer_regex_subscription_mode> REGEX_SUBSCRIPTION_MODE = {
58+ {" PersistentOnly" , pulsar_consumer_regex_sub_mode_PersistentOnly},
59+ {" NonPersistentOnly" , pulsar_consumer_regex_sub_mode_NonPersistentOnly},
60+ {" AllTopics" , pulsar_consumer_regex_sub_mode_AllTopics}};
61+
5662static const std::map<std::string, initial_position> INIT_POSITION = {
5763 {" Latest" , initial_position_latest}, {" Earliest" , initial_position_earliest}};
5864
@@ -111,6 +117,16 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
111117 }
112118 }
113119
120+ if (consumerConfig.Has (CFG_REGEX_SUBSCRIPTION_MODE) &&
121+ consumerConfig.Get (CFG_REGEX_SUBSCRIPTION_MODE).IsString ()) {
122+ std::string regexSubscriptionMode =
123+ consumerConfig.Get (CFG_REGEX_SUBSCRIPTION_MODE).ToString ().Utf8Value ();
124+ if (REGEX_SUBSCRIPTION_MODE.count (regexSubscriptionMode)) {
125+ pulsar_consumer_configuration_set_regex_subscription_mode (
126+ this ->cConsumerConfig .get (), REGEX_SUBSCRIPTION_MODE.at (regexSubscriptionMode));
127+ }
128+ }
129+
114130 if (consumerConfig.Has (CFG_CONSUMER_NAME) && consumerConfig.Get (CFG_CONSUMER_NAME).IsString ()) {
115131 std::string consumerName = consumerConfig.Get (CFG_CONSUMER_NAME).ToString ().Utf8Value ();
116132 if (!consumerName.empty ())
0 commit comments