Now topic-level policies are unified but the namespace-level policies are not and have the following problems:
There are instructions in broker.conf
, equal to 0 means disabled,but these policies can not be disabled now.
E.g: The comment of maxConsumersPerSubscription
in broker.conf is :
Using a value of 0, is disabling maxConsumersPerSubscription-limit check.The disabling of all other parameters is similar, all 0 means disabled.
But in Policies.java
, the default value of maxConsumersPerSubscription is: public int max_consumers_per_subscription = 0;
Now the disabling does not take effect, and we cannot recognize whether the namespace-level is not set or whether it needs to be disabled. Why don't we use -1 or 0 to mean it is not set?
Now -1 is rare, most of them are 0 or null. Change 0 and null to -1, or change -1 and null to 0, there will be compatibility issues as well. All topic-level use null, which can be consistent.
>
0: has been set<
0: not limited (Some need infinity, such as : retention)applied
interfaces at the topic level: Integer getMessageTTL(String topic, boolean applied)
When applied = true, if the topic-level has a policy, it will return, otherwise it will return the broker-level, if not, it will return thebroker-level
When applied = false, it only return the value of current level
int
becomes Integer
, can return null. Now topic-level policies are all in this way, but there are several configuration items of namespace-level still use basic types, and we will make namespace-level also be like topic-level.This will cause some existing interfaces to not be fully compatible. When the lower version of the SDK queries the new version of the broker with no value, NPE will appear. Since the previous disabled did not take effect, the value stored in zk is 0. If the broker is upgraded, the disabled will take effect. This is not directly related to modifying the API, as long as the bug is fixed, this problem will occur.
Interfaces that are incompatible and disabled
will take effect: