BewareMyPower commented on code in PR #237:
URL: https://github.com/apache/pulsar-client-cpp/pull/237#discussion_r1172314612
##########
include/pulsar/c/consumer_configuration.h:
##########
@@ -98,6 +98,21 @@ typedef struct {
long timeoutMs;
} pulsar_consumer_batch_receive_policy_t;
+typedef struct {
+ // Name of the dead topic where the failing messages are sent.
+ // The default value is: sourceTopicName + "-" + subscriptionName + "-DLQ"
+ const char *dead_letter_topic;
+ // Maximum number of times that a message is redelivered before being sent
to the dead letter queue.
+ // - The maxRedeliverCount must be greater than 0.
+ // - The default value is {INT_MAX} (DLQ is not enabled)
+ const int max_redeliver_count;
+ // Name of the initial subscription name of the dead letter topic.
+ // If this field is not set, the initial subscription for the dead letter
topic is not created.
+ // If this field is set but the broker's `allowAutoSubscriptionCreation`
is disabled, the DLQ producer
+ // fails to be created.
+ const char *initial_subscription_name;
+} pulsar_consumer_config_dead_letter_policy_t;
Review Comment:
This PR does not handle the default values well. We have to assign each
values explicitly. For example, if users only want to set the DLQ topic name,
they might write code like:
```c++
pulsar_consumer_config_dead_letter_policy_t policy = {.dead_letter_topic
= "dlq-topic"};
pulsar_consumer_configuration_t* conf =
pulsar_consumer_configuration_create();
pulsar_consumer_configuration_set_dlq_policy(conf, &policy);
pulsar_consumer_config_dead_letter_policy_t policy2 =
pulsar_consumer_configuration_get_dlq_policy(conf);
printf("%s | %d | %s\n", policy2.dead_letter_topic,
policy2.max_redeliver_count,
policy2.initial_subscription_name);
pulsar_consumer_configuration_free(conf);
```
The output is:
```
unknown file: Failure
C++ exception with description "maxRedeliverCount must be > 0." thrown in
the test body.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]