This message was deleted.
# general
s
This message was deleted.
a
Yes
a
@jihong do you want to do it using the Java admin API or with the admin-cli ?
a
Java admin API
a
In that case you will have to use
admin.topicPolicies().setRetention(String topic, RetentionPolicies policies)
j
Yes, using the java admin api, thank you very much for your answer!
👍 1
a
@Alexander Preuß, this is working, thanks a ton!! Sharing the solution snippet in the thread,
Copy code
public void setTopicRetentionPolicy(
      Long tenantId,
      String tenantName,
      Env env,
      String namespaceName,
      String topicName,
      int retentionTimeInMinutes) {
    PulsarAdmin pulsarAdmin = getPulsarAdmin(tenantId, env, PulsarRole.ADMIN);
    RetentionPolicies policies = new RetentionPolicies(retentionTimeInMinutes, -1);
    pulsarAdmin
        .topicPolicies()
        .setRetention(getTopicName(tenantName, namespaceName, topicName), policies);
  }