From d78610a80bb6bfee23474cc3bf978fd7ab2491c8 Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Fri, 28 Jan 2022 10:44:25 +0800 Subject: [PATCH 1/4] [Doc] Add doc for init sub config in DLQ policy and producer Motivation This PR is the doc for #13355 Modification * Add doc for init sub config in DLQ policy and producer Signed-off-by: Zike Yang --- site2/docs/client-libraries-java.md | 1 + site2/docs/concepts-messaging.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/site2/docs/client-libraries-java.md b/site2/docs/client-libraries-java.md index 9c725354acff8..7aa3a75114a47 100644 --- a/site2/docs/client-libraries-java.md +++ b/site2/docs/client-libraries-java.md @@ -208,6 +208,7 @@ Name| Type |
Description
| Default `batchingMaxMessages` |int|The maximum number of messages permitted in a batch.|1000 `batchingEnabled`| boolean|Enable batching of messages. |true `compressionType`|CompressionType|Message data compression type used by a producer.
Available options:
  • [`LZ4`](https://github.com/lz4/lz4)
  • [`ZLIB`](https://zlib.net/)
  • [`ZSTD`](https://facebook.github.io/zstd/)
  • [`SNAPPY`](https://google.github.io/snappy/)
  • | No compression +`initialSubscriptionName`|string|Use this config to automatically create an initial subscription when creating the topic. If this field is not set, the initial subscription will not be created.|null You can configure parameters if you do not want to use the default configuration. diff --git a/site2/docs/concepts-messaging.md b/site2/docs/concepts-messaging.md index bd9d23c892fd6..66a8a2e4d5681 100644 --- a/site2/docs/concepts-messaging.md +++ b/site2/docs/concepts-messaging.md @@ -302,6 +302,22 @@ Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) ``` +When creating a DLQ topic, there is no subscription by default, so if you don't subscribe to this topic in time, you may lose some messages in the DLQ. You can specify the `initSubscriptionName` to make it automatically create the initial subscription on the DLQ. + +```java +Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) + .topic(topic) + .subscriptionName("my-subscription") + .subscriptionType(SubscriptionType.Shared) + .deadLetterPolicy(DeadLetterPolicy.builder() + .maxRedeliverCount(maxRedeliveryCount) + .deadLetterTopic("your-topic-name") + .initSubscriptionName("init-sub") + .build()) + .subscribe(); + +``` + Dead letter topic depends on message redelivery. Messages are redelivered either due to [acknowledgement timeout](#acknowledgement-timeout) or [negative acknowledgement](#negative-acknowledgement). If you are going to use negative acknowledgement on a message, make sure it is negatively acknowledged before the acknowledgement timeout. > **Note** From a2e909daf4658a91a4e6a2ca45b5caabd7ce9f20 Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Fri, 28 Jan 2022 11:06:14 +0800 Subject: [PATCH 2/4] Update site2/docs/concepts-messaging.md Co-authored-by: momo-jun <60642177+momo-jun@users.noreply.github.com> --- site2/docs/concepts-messaging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site2/docs/concepts-messaging.md b/site2/docs/concepts-messaging.md index 66a8a2e4d5681..3aa129e47c418 100644 --- a/site2/docs/concepts-messaging.md +++ b/site2/docs/concepts-messaging.md @@ -302,7 +302,7 @@ Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) ``` -When creating a DLQ topic, there is no subscription by default, so if you don't subscribe to this topic in time, you may lose some messages in the DLQ. You can specify the `initSubscriptionName` to make it automatically create the initial subscription on the DLQ. +By default, there is no subscription during a DLQ topic creation. Without a just-in-time subscription to the DLQ topic, you may lose messages. To automatically create the initial subscription for the DLQ, you can specify the initSubscriptionName parameter. ```java Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) From fed8e29b0cd54a7ba85a5c312c83469370aebce6 Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Sat, 29 Jan 2022 20:25:31 +0800 Subject: [PATCH 3/4] Rename `initSubscriptionName` to `initialSubscriptionName` Signed-off-by: Zike Yang --- site2/docs/concepts-messaging.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site2/docs/concepts-messaging.md b/site2/docs/concepts-messaging.md index 3aa129e47c418..2c9d15cbfc837 100644 --- a/site2/docs/concepts-messaging.md +++ b/site2/docs/concepts-messaging.md @@ -302,7 +302,7 @@ Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) ``` -By default, there is no subscription during a DLQ topic creation. Without a just-in-time subscription to the DLQ topic, you may lose messages. To automatically create the initial subscription for the DLQ, you can specify the initSubscriptionName parameter. +By default, there is no subscription during a DLQ topic creation. Without a just-in-time subscription to the DLQ topic, you may lose messages. To automatically create the initial subscription for the DLQ, you can specify the initialSubscriptionName parameter. ```java Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) @@ -312,7 +312,7 @@ Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) .deadLetterPolicy(DeadLetterPolicy.builder() .maxRedeliverCount(maxRedeliveryCount) .deadLetterTopic("your-topic-name") - .initSubscriptionName("init-sub") + .initialSubscriptionName("init-sub") .build()) .subscribe(); From 1eecb027360bd5a1c6a6b5075dbb69050af1a1ca Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Mon, 7 Feb 2022 16:14:11 +0800 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Anonymitaet <50226895+Anonymitaet@users.noreply.github.com> --- site2/docs/client-libraries-java.md | 2 +- site2/docs/concepts-messaging.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/site2/docs/client-libraries-java.md b/site2/docs/client-libraries-java.md index 7aa3a75114a47..fe65d9028460a 100644 --- a/site2/docs/client-libraries-java.md +++ b/site2/docs/client-libraries-java.md @@ -208,7 +208,7 @@ Name| Type |
    Description
    | Default `batchingMaxMessages` |int|The maximum number of messages permitted in a batch.|1000 `batchingEnabled`| boolean|Enable batching of messages. |true `compressionType`|CompressionType|Message data compression type used by a producer.
    Available options:
  • [`LZ4`](https://github.com/lz4/lz4)
  • [`ZLIB`](https://zlib.net/)
  • [`ZSTD`](https://facebook.github.io/zstd/)
  • [`SNAPPY`](https://google.github.io/snappy/)
  • | No compression -`initialSubscriptionName`|string|Use this config to automatically create an initial subscription when creating the topic. If this field is not set, the initial subscription will not be created.|null +`initialSubscriptionName`|string|Use this configuration to automatically create an initial subscription when creating a topic. If this field is not set, the initial subscription is not created.|null You can configure parameters if you do not want to use the default configuration. diff --git a/site2/docs/concepts-messaging.md b/site2/docs/concepts-messaging.md index 2c9d15cbfc837..32626df8ddb01 100644 --- a/site2/docs/concepts-messaging.md +++ b/site2/docs/concepts-messaging.md @@ -302,7 +302,7 @@ Consumer consumer = pulsarClient.newConsumer(Schema.BYTES) ``` -By default, there is no subscription during a DLQ topic creation. Without a just-in-time subscription to the DLQ topic, you may lose messages. To automatically create the initial subscription for the DLQ, you can specify the initialSubscriptionName parameter. +By default, there is no subscription during a DLQ topic creation. Without a just-in-time subscription to the DLQ topic, you may lose messages. To automatically create an initial subscription for the DLQ, you can specify the `initialSubscriptionName` parameter. ```java Consumer consumer = pulsarClient.newConsumer(Schema.BYTES)