lhotari commented on code in PR #23449:
URL: https://github.com/apache/pulsar/pull/23449#discussion_r1799874110
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -308,8 +308,29 @@ private CompletableFuture<Void>
addConsumerInternal(Consumer consumer) {
}
} else {
if (consumer.subType() != dispatcher.getType()) {
- return FutureUtil.failedFuture(
- new SubscriptionBusyException("Subscription is
of different type"));
+ return FutureUtil.failedFuture(new
SubscriptionBusyException(
+ 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())));
+ } 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(
+ String.format("Subscription is of
different type. Active subscription key_shared "
+ + "mode of '%s' is
different than the connecting consumer's "
+ + "key_shared mode '%s'.",
+ dispatcherKsm.getKeySharedMode(),
consumerKsm.getKeySharedMode())));
+ }
+ if (dispatcherKsm.isAllowOutOfOrderDelivery() !=
consumerKsm.isAllowOutOfOrderDelivery()) {
+ return FutureUtil.failedFuture(new
SubscriptionBusyException(
+ String.format("Subscription is of
different type. %s",
+
dispatcherKsm.isAllowOutOfOrderDelivery()
+ ? "Active subscription
allows out of order delivery while the "
+ + "connecting consumer
does not allow it." :
+ "Active subscription does
not allow out of order delivery while "
+ + "the connecting
consumer allows it.")));
+ }
Review Comment:
reduce duplication with the method extracted in the previous step
--
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]