Skip to content

Commit 965b3ee

Browse files
committed
Fix code review
1 parent e818ead commit 965b3ee

5 files changed

+43
-7
lines changed

include/pulsar/ConsumerConfiguration.h

+24-2
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,30 @@ class PULSAR_PUBLIC ConsumerConfiguration {
400400
const BatchReceivePolicy& getBatchReceivePolicy() const;
401401

402402
/**
403-
* Set dead letter policy.
404-
*
403+
* Set dead letter policy for consumer
404+
*
405+
* By default some message will redelivery so many times possible, even to the extent that it can be never
406+
* stop. By using dead letter mechanism messages will has the max redelivery count, when message exceeding
407+
* the maximum number of redeliveries, message will send to the Dead Letter Topic and acknowledged
408+
* automatic.
409+
*
410+
* You can enable the dead letter mechanism by setting dead letter policy.
411+
* example:
412+
*
413+
* <pre>
414+
* * DeadLetterPolicy dlqPolicy = DeadLetterPolicyBuilder()
415+
* .maxRedeliverCount(10)
416+
* .build();
417+
* </pre>
418+
* Default dead letter topic name is {TopicName}-{Subscription}-DLQ.
419+
* To setting a custom dead letter topic name
420+
* <pre>
421+
* DeadLetterPolicy dlqPolicy = DeadLetterPolicyBuilder()
422+
* .deadLetterTopic("dlq-topic")
423+
* .maxRedeliverCount(10)
424+
* .initialSubscriptionName("init-sub-name")
425+
* .build();
426+
* </pre>
405427
* @param deadLetterPolicy thd default is empty
406428
*/
407429
void setDeadLetterPolicy(const DeadLetterPolicy& deadLetterPolicy);

include/pulsar/DeadLetterPolicyBuilder.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ class PULSAR_PUBLIC DeadLetterPolicyBuilder {
4646
DeadLetterPolicyBuilder();
4747

4848
/**
49-
* Set dead letter topic
49+
* Set dead letter topic.
50+
*
51+
* @param deadLetterTopic Name of the dead topic where the failing messages will be sent.
52+
* The default value is: sourceTopicName + "-" + subscriptionName + "-DLQ"
5053
*
5154
* @return
5255
*/
@@ -55,13 +58,23 @@ class PULSAR_PUBLIC DeadLetterPolicyBuilder {
5558
/**
5659
* Set max redeliver count
5760
*
61+
* @param maxRedeliverCount Maximum number of times that a message will be redelivered before being sent
62+
* to the dead letter queue.
63+
* - The maxRedeliverCount must be greater than 0.
64+
* - The default value is {INT_MAX} (DLQ is not enabled)
65+
*
5866
* @return
5967
*/
6068
DeadLetterPolicyBuilder& maxRedeliverCount(int maxRedeliverCount);
6169

6270
/**
6371
* Set initial subscription name
6472
*
73+
* @param initialSubscriptionName Name of the initial subscription name of the dead letter topic.
74+
* If this field is not set, the initial subscription for the dead letter topic will not be created.
75+
* If this field is set but the broker's `allowAutoSubscriptionCreation` is disabled, the DLQ producer
76+
* will fail to be created.
77+
*
6578
* @return
6679
*/
6780
DeadLetterPolicyBuilder& initialSubscriptionName(const std::string& initialSubscriptionName);

lib/DeadLetterPolicyImpl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
#pragma once
2020

21-
#include "climits"
22-
#include "string"
21+
#include <climits>
22+
#include <string>
2323

2424
namespace pulsar {
2525

tests/ConsumerConfigurationTest.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727
DECLARE_LOG_OBJECT()
2828

29+
#include <pulsar/DeadLetterPolicyBuilder.h>
30+
2931
#include "../lib/Future.h"
3032
#include "../lib/Utils.h"
31-
#include "pulsar/DeadLetterPolicyBuilder.h"
3233

3334
using namespace pulsar;
3435

tests/DeadLetterQueueTest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
#include <gtest/gtest.h>
2020
#include <pulsar/Client.h>
21+
#include <pulsar/DeadLetterPolicyBuilder.h>
2122

2223
#include "HttpHelper.h"
2324
#include "PulsarFriend.h"
@@ -26,7 +27,6 @@
2627
#include "lib/MessageIdUtil.h"
2728
#include "lib/UnAckedMessageTrackerEnabled.h"
2829
#include "lib/Utils.h"
29-
#include "pulsar/DeadLetterPolicyBuilder.h"
3030

3131
static const std::string lookupUrl = "pulsar://localhost:6650";
3232
static const std::string adminUrl = "http://localhost:8080/";

0 commit comments

Comments
 (0)