lhotari commented on code in PR #23449:
URL: https://github.com/apache/pulsar/pull/23449#discussion_r1798959477
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -310,6 +310,19 @@ private CompletableFuture<Void>
addConsumerInternal(Consumer consumer) {
if (consumer.subType() != dispatcher.getType()) {
return FutureUtil.failedFuture(
new SubscriptionBusyException("Subscription is
of different type"));
+ } else if (dispatcher.getType() == SubType.Key_Shared) {
+ KeySharedMeta dispatcherKsm =
dispatcher.getConsumers().get(0).getKeySharedMeta();
+ KeySharedMeta consumerKsm =
consumer.getKeySharedMeta();
+ if (dispatcherKsm.getKeySharedMode() !=
consumerKsm.getKeySharedMode()) {
+ return FutureUtil.failedFuture(
+ new
SubscriptionBusyException("Subscription is of different key_shared mode"));
+ }
+ if (dispatcherKsm.isAllowOutOfOrderDelivery() !=
consumerKsm.isAllowOutOfOrderDelivery()) {
+ return FutureUtil.failedFuture(
+ new
SubscriptionBusyException(dispatcherKsm.isAllowOutOfOrderDelivery()
+ ? "Subscription allows out of
order delivery" :
+ "Subscription does not allow out
of order delivery"));
Review Comment:
@pdolif These error messages are a bit vague. It's already an issue with the
existing "Subscription is of different type" exception. It's currently hard to
determine which mode is active on the broker side and which is the mode on the
client.
Something like this for all error messages could be helpful:
`"Subscription is of different type"` -> `String.format("Subscription is of
different type. Active subscription type of '%s' is different than the
connecting consumer's type '%s'", dispatcher.getType(), consumer.subType())`
etc.
It might be useful to keep "Subscription is of different type" as the prefix
for all errors since there might be client applications that are looking for
that String since there's no unique exception for this problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]