From ecacc9bc4538aac11337beb6ddd333c108501d88 Mon Sep 17 00:00:00 2001 From: Jinfeng Huang Date: Wed, 28 Oct 2020 15:49:52 +0800 Subject: [PATCH 1/5] add retention policy --- site2/docs/cookbooks-retention-expiry.md | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/site2/docs/cookbooks-retention-expiry.md b/site2/docs/cookbooks-retention-expiry.md index 286f0ff2a37ea..48bc6fab5091c 100644 --- a/site2/docs/cookbooks-retention-expiry.md +++ b/site2/docs/cookbooks-retention-expiry.md @@ -27,37 +27,38 @@ Pulsar's [admin interface](admin-api-overview.md) enables you to manage both ret ## Retention policies -By default, when a Pulsar message arrives at a broker it will be stored until it has been acknowledged on all subscriptions, at which point it will be marked for deletion. You can override this behavior and retain even messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention is based on both a *size limit* and a *time limit*. +By default, when a Pulsar message arrives at a broker, the message is stored until it has been acknowledged on all subscriptions, at which point it is marked for deletion. You can override this behavior and retain even messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention is based on both a *size limit* and a *time limit*. -Retention policies are particularly useful if you intend to exclusively use the Reader interface. Because the Reader interface does not use acknowledgements, messages will never exist within backlogs. Most realistic Reader-only use cases require that retention be configured. +Retention policies are useful when you use the Reader interface. The Reader interface does not use acknowledgements, and messages do not exist within backlogs. It is required to configure retention for Reader-only use cases. -When you set a retention policy you must set **both** a *size limit* and a *time limit*. In the case where you don't want to limit by either time or set, the value must be set to `-1`. Retention policy will be effectively disabled and it won't prevent the deletion of acknowledged messages when either size or time limit is set to `0`. Infinite retention can be achieved by setting both time and size limits to `-1`. +When you set a retention policy, you must set **both** a *size limit* and a *time limit*. -When you set a size limit of, say, 10 gigabytes, and the time limit to `-1` then acknowledged messages in all topics in the namespace will be retained until the size limit for the topic is reached; if you set a time limit of, say, 1 day, and the size limit to `-1` then acknowledged messages for all topics in the namespace will be retained for 24 hours. +- If you do not want to limit the message by time, set the value of time limit to `-1`. +- If you do not want to limit the message by size, set the value of size limit to `-1`. +- If you need infinite retention, set the values of time limit and size limit to `-1`. +- If you want to disable retention policy, set the values of time limit and size limit to `0`. Retention policy is disabled by default. -The retention settings apply to all messages on topics that do not have any subscriptions, or if there are subscriptions, to messages that have been acked by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions -- these are instead controlled by the backlog quota (see below). +When you set a size limit of, for example, 10 gigabytes, and set the time limit to `-1`, then the acknowledged messages in all topics in the namespace are retained until the topic size reaches the limit(10 gigabytes). If you set a time limit of, for example, 1 day, and set the size limit to `-1`, then the acknowledged messages for all topics in the namespace are retained for 24 hours. + +The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acked by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. When a retention limit is exceeded, the oldest message is marked for deletion until the set of retained messages falls within the specified limits again. ### Defaults -There are two configuration parameters that you can use to set [instance](reference-terminology.md#instance)-wide defaults for message retention: [`defaultRetentionTimeInMinutes=0`](reference-configuration.md#broker-defaultRetentionTimeInMinutes) and [`defaultRetentionSizeInMB=0`](reference-configuration.md#broker-defaultRetentionSizeInMB). +You can use the following two configuration parameters to set [instance](reference-terminology.md#instance)-wide defaults for message retention: [`defaultRetentionTimeInMinutes=0`](reference-configuration.md#broker-defaultRetentionTimeInMinutes) and [`defaultRetentionSizeInMB=0`](reference-configuration.md#broker-defaultRetentionSizeInMB). Both of these parameters are in the [`broker.conf`](reference-configuration.md#broker) configuration file. ### Set retention policy -You can set a retention policy for a namespace by specifying the namespace as well as both a size limit *and* a time limit. - -#### pulsar-admin - -Use the [`set-retention`](reference-pulsar-admin.md#namespaces-set-retention) subcommand and specify a namespace, a size limit using the `-s`/`--size` flag, and a time limit using the `-t`/`--time` flag. - -You must set **both** a *size limit* and a *time limit*. In the case where you don't want to limit by either time or set, the value must be set to `-1`. Retention policy will be effectively disabled and it won't prevent the deletion of acknowledged messages when either size or time limit is set to 0. +You can set a retention policy for a namespace by specifying the namespace as well as both a size limit *and* a time limit in `pulsar-admin`, REST API and Java. -##### Examples + + +You can use the [`set-retention`](reference-pulsar-admin.md#namespaces-set-retention) subcommand and specify a namespace, a size limit using the `-s`/`--size` flag, and a time limit using the `-t`/`--time` flag. -To set a size limit of 10 gigabytes and a time limit of 3 hours for the `my-tenant/my-ns` namespace: +In the following example, size limit is set to 10 gigabytes and time limit is set to 3 hours for the `my-tenant/my-ns` namespace: ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -65,7 +66,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 3h ``` -To set retention where time limit is ignored and the size limit of 1 terabyte determines retention: +In the following example, time is not limited and size limit is set to 1 terabyte. The size limit determines the retention result. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -73,7 +74,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time -1 ``` -To set retention where size limit is ignored and the time limit of 3 hours determines retention: +In the following example, size is not limited and time limit is set to 3 hours. The time limit determines the retention result. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -81,7 +82,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 3h ``` -To set infinite retention: +To set infinite retention, set both values to `-1`. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -89,7 +90,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time -1 ``` -To disable the retention policy +To disable the retention policy, set both values to `0`. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -97,13 +98,10 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 0 ``` - -#### REST API - + {@inject: endpoint|POST|/admin/v2/namespaces/:tenant/:namespace/retention|operation/setRetention} -#### Java - + ```java int retentionTime = 10; // 10 minutes int retentionSize = 500; // 500 megabytes @@ -111,6 +109,8 @@ RetentionPolicies policies = new RetentionPolicies(retentionTime, retentionSize) admin.namespaces().setRetention(namespace, policies); ``` + + ### Get retention policy You can fetch the retention policy for a namespace by specifying the namespace. The output will be a JSON object with two keys: `retentionTimeInMinutes` and `retentionSizeInMB`. From 7e74f5174fd59eea6aba8cc87ec10e07f9c1fe57 Mon Sep 17 00:00:00 2001 From: Jinfeng Huang Date: Wed, 28 Oct 2020 16:02:47 +0800 Subject: [PATCH 2/5] fix the default vaule for retention --- site2/docs/cookbooks-retention-expiry.md | 10 +++++----- site2/docs/reference-configuration.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/site2/docs/cookbooks-retention-expiry.md b/site2/docs/cookbooks-retention-expiry.md index 48bc6fab5091c..202d2ac6bbb7f 100644 --- a/site2/docs/cookbooks-retention-expiry.md +++ b/site2/docs/cookbooks-retention-expiry.md @@ -27,7 +27,7 @@ Pulsar's [admin interface](admin-api-overview.md) enables you to manage both ret ## Retention policies -By default, when a Pulsar message arrives at a broker, the message is stored until it has been acknowledged on all subscriptions, at which point it is marked for deletion. You can override this behavior and retain even messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention is based on both a *size limit* and a *time limit*. +By default, when a Pulsar message arrives at a broker, the message is stored until it has been acknowledged on all subscriptions, at which point it is marked for deletion. You can override this behavior and retain messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention is based on both a *size limit* and a *time limit*. Retention policies are useful when you use the Reader interface. The Reader interface does not use acknowledgements, and messages do not exist within backlogs. It is required to configure retention for Reader-only use cases. @@ -38,7 +38,7 @@ When you set a retention policy, you must set **both** a *size limit* and a *tim - If you need infinite retention, set the values of time limit and size limit to `-1`. - If you want to disable retention policy, set the values of time limit and size limit to `0`. Retention policy is disabled by default. -When you set a size limit of, for example, 10 gigabytes, and set the time limit to `-1`, then the acknowledged messages in all topics in the namespace are retained until the topic size reaches the limit(10 gigabytes). If you set a time limit of, for example, 1 day, and set the size limit to `-1`, then the acknowledged messages for all topics in the namespace are retained for 24 hours. +When you set a size limit of, for example, 10 gigabytes, and set the time limit to `-1`, then the acknowledged messages in all topics in the namespace are retained until the topic size reaches the size limit(10 gigabytes). If you set a time limit of, for example, 1 day, and set the size limit to `-1`, then the acknowledged messages for all topics in the namespace are retained for 1 day. The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acked by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. @@ -46,13 +46,13 @@ When a retention limit is exceeded, the oldest message is marked for deletion un ### Defaults -You can use the following two configuration parameters to set [instance](reference-terminology.md#instance)-wide defaults for message retention: [`defaultRetentionTimeInMinutes=0`](reference-configuration.md#broker-defaultRetentionTimeInMinutes) and [`defaultRetentionSizeInMB=0`](reference-configuration.md#broker-defaultRetentionSizeInMB). +You can use the following two configuration parameters to set instance-wide defaults for message retention: `defaultRetentionTimeInMinutes` and `defaultRetentionSizeInMB`. Both parameters are set to `0` by default. -Both of these parameters are in the [`broker.conf`](reference-configuration.md#broker) configuration file. +For more information of the two parameters, refer to the [`broker.conf`](reference-configuration.md#broker) configuration file. ### Set retention policy -You can set a retention policy for a namespace by specifying the namespace as well as both a size limit *and* a time limit in `pulsar-admin`, REST API and Java. +You can set a retention policy for a namespace by specifying the namespace, a size limit and a time limit in `pulsar-admin`, REST API and Java. diff --git a/site2/docs/reference-configuration.md b/site2/docs/reference-configuration.md index af9ed0f0b0611..67ed800984d19 100644 --- a/site2/docs/reference-configuration.md +++ b/site2/docs/reference-configuration.md @@ -305,7 +305,7 @@ subscriptionExpirationTimeMinutes | How long to delete inactive subscriptions fr |brokerServicePurgeInactiveFrequencyInSeconds|Deprecated. Use `brokerDeleteInactiveTopicsFrequencySeconds`.|60| |transactionCoordinatorEnabled|Whether to enable transaction coordinator in broker.|true| |transactionMetadataStoreProviderClassName| |org.apache.pulsar.transaction.coordinator.impl.InMemTransactionMetadataStoreProvider| -|defaultRetentionTimeInMinutes| Default message retention time || +|defaultRetentionTimeInMinutes| Default message retention time |0| |defaultRetentionSizeInMB| Default retention size |0| |keepAliveIntervalSeconds| How often to check whether the connections are still alive |30| |bootstrapNamespaces| The bootstrap name. | N/A | From 3b4681e8f979378526c0d69d94d8a8ae6a9b6a0f Mon Sep 17 00:00:00 2001 From: Jinfeng Huang Date: Thu, 29 Oct 2020 16:43:09 +0800 Subject: [PATCH 3/5] add detailed retention info --- site2/docs/cookbooks-retention-expiry.md | 34 +++++---- .../cookbooks-retention-expiry.md | 74 ++++++++++++++----- 2 files changed, 76 insertions(+), 32 deletions(-) diff --git a/site2/docs/cookbooks-retention-expiry.md b/site2/docs/cookbooks-retention-expiry.md index 202d2ac6bbb7f..995be4d6a00c9 100644 --- a/site2/docs/cookbooks-retention-expiry.md +++ b/site2/docs/cookbooks-retention-expiry.md @@ -31,22 +31,25 @@ By default, when a Pulsar message arrives at a broker, the message is stored unt Retention policies are useful when you use the Reader interface. The Reader interface does not use acknowledgements, and messages do not exist within backlogs. It is required to configure retention for Reader-only use cases. -When you set a retention policy, you must set **both** a *size limit* and a *time limit*. +When you set a retention policy, you must set **both** a *size limit* and a *time limit*. You can refer to the following table to set retention policies in `pulsar-admin` and Java. -- If you do not want to limit the message by time, set the value of time limit to `-1`. -- If you do not want to limit the message by size, set the value of size limit to `-1`. -- If you need infinite retention, set the values of time limit and size limit to `-1`. -- If you want to disable retention policy, set the values of time limit and size limit to `0`. Retention policy is disabled by default. +|Time limit|Size limit| Message retention | +|----------|----------|------------------------| +| -1 | -1 | Infinite retention | +| -1 | >0 | Based on the size limit | +| >0 | -1 | Based on the time limit | +| 0 | 0 | Disable message retention(by default) | +| 0 | >0 | Invalid | +| >0 | 0 | Invalid | +| >0 | >0 | Messages are deleted when either time or size reaches the limit | -When you set a size limit of, for example, 10 gigabytes, and set the time limit to `-1`, then the acknowledged messages in all topics in the namespace are retained until the topic size reaches the size limit(10 gigabytes). If you set a time limit of, for example, 1 day, and set the size limit to `-1`, then the acknowledged messages for all topics in the namespace are retained for 1 day. - -The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acked by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. +The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. When a retention limit is exceeded, the oldest message is marked for deletion until the set of retained messages falls within the specified limits again. ### Defaults -You can use the following two configuration parameters to set instance-wide defaults for message retention: `defaultRetentionTimeInMinutes` and `defaultRetentionSizeInMB`. Both parameters are set to `0` by default. +You can set message retention at instance level with the following two parameters: `defaultRetentionTimeInMinutes` and `defaultRetentionSizeInMB`. Both parameters are set to `0` by default. For more information of the two parameters, refer to the [`broker.conf`](reference-configuration.md#broker) configuration file. @@ -58,7 +61,9 @@ You can set a retention policy for a namespace by specifying the namespace, a si You can use the [`set-retention`](reference-pulsar-admin.md#namespaces-set-retention) subcommand and specify a namespace, a size limit using the `-s`/`--size` flag, and a time limit using the `-t`/`--time` flag. -In the following example, size limit is set to 10 gigabytes and time limit is set to 3 hours for the `my-tenant/my-ns` namespace: +In the following example, the size limit is set to 10 GB and the time limit is set to 3 hours for the `my-tenant/my-ns` namespace. +- When the message size reaches 10 GB within 3 hours, the acknowledged messages will not be retained. +- After 3 hours, even the message size is less than 10 GB, the acknowledged messages will not be retained. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -66,7 +71,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 3h ``` -In the following example, time is not limited and size limit is set to 1 terabyte. The size limit determines the retention result. +In the following example, the time is not limited and the size limit is set to 1 TB. The size limit determines the retention. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -74,7 +79,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time -1 ``` -In the following example, size is not limited and time limit is set to 3 hours. The time limit determines the retention result. +In the following example, the size is not limited and the time limit is set to 3 hours. The time limit determines the retention. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -82,7 +87,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 3h ``` -To set infinite retention, set both values to `-1`. +To achieve infinite retention, set both values to `-1`. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -101,6 +106,9 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ {@inject: endpoint|POST|/admin/v2/namespaces/:tenant/:namespace/retention|operation/setRetention} +> **Note** +> To disable the retention policy, you need to set both the size and time limit to `0`. Set either size or time limit to `0` is invalid. + ```java int retentionTime = 10; // 10 minutes diff --git a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md index 6b796dc9cde49..3b1bd68c6d4ba 100644 --- a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md +++ b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md @@ -28,33 +28,43 @@ Pulsar's [admin interface](admin-api-overview.md) enables you to manage both ret ## Retention policies -By default, when a Pulsar message arrives at a broker it will be stored until it has been acknowledged on all subscriptions, at which point it will be marked for deletion. You can override this behavior and retain even messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention policies are either a *size limit* or a *time limit*. +By default, when a Pulsar message arrives at a broker, the message is stored until it has been acknowledged on all subscriptions, at which point it is marked for deletion. You can override this behavior and retain messages that have already been acknowledged on all subscriptions by setting a *retention policy* for all topics in a given namespace. Retention is based on both a *size limit* and a *time limit*. -Retention policies are particularly useful if you intend to exclusively use the Reader interface. Because the Reader interface does not use acknowledgements, messages will never exist within backlogs. Most realistic Reader-only use cases require that retention be configured. +Retention policies are useful when you use the Reader interface. The Reader interface does not use acknowledgements, and messages do not exist within backlogs. It is required to configure retention for Reader-only use cases. -When you set a size limit of, say, 10 gigabytes, then acknowledged messages in all topics in the namespace will be retained until the size limit for the topic is reached; if you set a time limit of, say, 1 day, then acknowledged messages for all topics in the namespace will be retained for 24 hours. The retention settings apply to all messages on topics that do not have any subscriptions, or if there are subscriptions, to messages that have been acked by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions -- these are instead controlled by the backlog quota (see below). +When you set a retention policy, you must set **both** a *size limit* and a *time limit*. You can refer to the following table to set retention policies. -When a retention limit is exceeded, the oldest message is marked for deletion until the set of retained messages falls within the specified limits again. +|Time limit|Size limit| Message retention | +|----------|----------|------------------------| +| -1 | -1 | Infinite retention | +| -1 | >0 | Based on the size limit | +| >0 | -1 | Based on the time limit | +| 0 | 0 | Disable message retention(by default) | +| 0 | >0 | Disable message retention | +| >0 | 0 | Disable message retention | +| >0 | >0 | Messages are deleted when either time or size reaches the limit | + +The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. -It is also possible to set *unlimited* retention time or size by setting `-1` for either time or size retention. +When a retention limit is exceeded, the oldest message is marked for deletion until the set of retained messages falls within the specified limits again. ### Defaults -There are two configuration parameters that you can use to set [instance](reference-terminology.md#instance)-wide defaults for message retention: [`defaultRetentionTimeInMinutes=0`](reference-configuration.md#broker-defaultRetentionTimeInMinutes) and [`defaultRetentionSizeInMB=0`](reference-configuration.md#broker-defaultRetentionSizeInMB). +You can set message retention at instance level with the following two parameters: `defaultRetentionTimeInMinutes` and `defaultRetentionSizeInMB`. Both parameters are set to `0` by default. -Both of these parameters are in the [`broker.conf`](reference-configuration.md#broker) configuration file. +For more information of the two parameters, refer to the [`broker.conf`](reference-configuration.md#broker) configuration file. ### Set retention policy -You can set a retention policy for a namespace by specifying the namespace as well as both a size limit *and* a time limit. - -#### pulsar-admin - -Use the [`set-retention`](reference-pulsar-admin.md#namespaces-set-retention) subcommand and specify a namespace, a size limit using the `-s`/`--size` flag, and a time limit using the `-t`/`--time` flag. +You can set a retention policy for a namespace by specifying the namespace, a size limit and a time limit in `pulsar-admin`, REST API and Java. -##### Examples + + +You can use the [`set-retention`](reference-pulsar-admin.md#namespaces-set-retention) subcommand and specify a namespace, a size limit using the `-s`/`--size` flag, and a time limit using the `-t`/`--time` flag. -To set a size limit of 10 gigabytes and a time limit of 3 hours for the `my-tenant/my-ns` namespace: +In the following example, the size limit is set to 10 GB and the time limit is set to 3 hours for the `my-tenant/my-ns` namespace. +- When the message size reaches 10 GB within 3 hours, the acknowledged messages will not be retained any more. +- At the time of 3 hours, even the message size is less than 10 GB, the acknowledged messages will not be retained. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -62,7 +72,7 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time 3h ``` -To set retention with a size limit but without a time limit: +In the following example, the time is not limited and the size limit is set to 1 TB. The size limit determines the retention. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -70,7 +80,15 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time -1 ``` -Retention can be configured to be unlimited both in size and time: +In the following example, the size is not limited and the time limit is set to 3 hours. The time limit determines the retention. + +```shell +$ pulsar-admin namespaces set-retention my-tenant/my-ns \ + --size -1 \ + --time 3h +``` + +To achieve infinite retention, set both values to `-1`. ```shell $ pulsar-admin namespaces set-retention my-tenant/my-ns \ @@ -78,14 +96,30 @@ $ pulsar-admin namespaces set-retention my-tenant/my-ns \ --time -1 ``` +To disable the retention policy, set either time limit or size limit to `0`. Message retention is disabled in the following examples. +```shell +$ pulsar-admin namespaces set-retention my-tenant/my-ns \ + --size 0 \ + --time 3h +``` -#### REST API +```shell +$ pulsar-admin namespaces set-retention my-tenant/my-ns \ + --size 10G \ + --time 0 +``` -{@inject: endpoint|POST|/admin/v2/namespaces/:tenant/:namespace/retention|operation/setRetention} +```shell +$ pulsar-admin namespaces set-retention my-tenant/my-ns \ + --size 0 \ + --time 0 +``` -#### Java + +{@inject: endpoint|POST|/admin/v2/namespaces/:tenant/:namespace/retention|operation/setRetention} + ```java int retentionTime = 10; // 10 minutes int retentionSize = 500; // 500 megabytes @@ -93,6 +127,8 @@ RetentionPolicies policies = new RetentionPolicies(retentionTime, retentionSize) admin.namespaces().setRetention(namespace, policies); ``` + + ### Get retention policy You can fetch the retention policy for a namespace by specifying the namespace. The output will be a JSON object with two keys: `retentionTimeInMinutes` and `retentionSizeInMB`. From 3b9d0424796cc427295f0b77c9c2373df906adf6 Mon Sep 17 00:00:00 2001 From: Jinfeng Huang Date: Thu, 29 Oct 2020 17:58:32 +0800 Subject: [PATCH 4/5] update --- site2/docs/cookbooks-retention-expiry.md | 2 +- .../versioned_docs/version-2.6.1/cookbooks-retention-expiry.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/site2/docs/cookbooks-retention-expiry.md b/site2/docs/cookbooks-retention-expiry.md index 995be4d6a00c9..38c22b19a46dd 100644 --- a/site2/docs/cookbooks-retention-expiry.md +++ b/site2/docs/cookbooks-retention-expiry.md @@ -41,7 +41,7 @@ When you set a retention policy, you must set **both** a *size limit* and a *tim | 0 | 0 | Disable message retention(by default) | | 0 | >0 | Invalid | | >0 | 0 | Invalid | -| >0 | >0 | Messages are deleted when either time or size reaches the limit | +| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained | The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. diff --git a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md index 3b1bd68c6d4ba..9b9f8cb1db4db 100644 --- a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md +++ b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md @@ -42,7 +42,7 @@ When you set a retention policy, you must set **both** a *size limit* and a *tim | 0 | 0 | Disable message retention(by default) | | 0 | >0 | Disable message retention | | >0 | 0 | Disable message retention | -| >0 | >0 | Messages are deleted when either time or size reaches the limit | +| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained | The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. From c5c26286ed72f3a596b9e0dba70f3602d8c0a350 Mon Sep 17 00:00:00 2001 From: Jinfeng Huang Date: Thu, 29 Oct 2020 18:16:53 +0800 Subject: [PATCH 5/5] update --- site2/docs/cookbooks-retention-expiry.md | 2 +- .../versioned_docs/version-2.6.1/cookbooks-retention-expiry.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/site2/docs/cookbooks-retention-expiry.md b/site2/docs/cookbooks-retention-expiry.md index 38c22b19a46dd..a5b7f2c35a05c 100644 --- a/site2/docs/cookbooks-retention-expiry.md +++ b/site2/docs/cookbooks-retention-expiry.md @@ -41,7 +41,7 @@ When you set a retention policy, you must set **both** a *size limit* and a *tim | 0 | 0 | Disable message retention(by default) | | 0 | >0 | Invalid | | >0 | 0 | Invalid | -| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained | +| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained when either time or size reaches the limit. | The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota. diff --git a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md index 9b9f8cb1db4db..54d5da551808e 100644 --- a/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md +++ b/site2/website/versioned_docs/version-2.6.1/cookbooks-retention-expiry.md @@ -42,7 +42,7 @@ When you set a retention policy, you must set **both** a *size limit* and a *tim | 0 | 0 | Disable message retention(by default) | | 0 | >0 | Disable message retention | | >0 | 0 | Disable message retention | -| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained | +| >0 | >0 | Acknowledged messages or messages with no active subscription will not be retained when either time or size reaches the limit.| The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota.